Positioning a dialog on a Facebook Canvas Page

Positioning a dialog on a Facebook Canvas Page

As promised (or threatened) here is a post on some little Facebook development insight gained through some trial, error, blood, sweat, and yes tears.

A problem I was having was accurately determining the x, y position of a given control for popping up informational dialogs. Sure, it was easy enough to use the getAbsoluteTop and getAbsoluteLeft calls to get the absolute positioning (supposed), but after playing around with these calls it became apparent that “absolute” didn’t mean “absolute” in the sense that most web / windows developers would understand. It really is a relative offset – but to what?

After perusing the FBJS docs, and finding no mention of a viewport (which is really what I was trying to determine the offset from), I took a total flier and thought – “well, if I could jet get the root element of my document, and find ITS x and y, I should be home free.

Bingo. That was the trick. Use document.getRootElement() to get the container element.

The code below demonstrates the technique.

var argCtl = document.getElementById(“myForm”);
var newTop = argCtl.getAbsoluteTop();
var newLeft = argCtl.getAbsoluteLeft();
var scrollW = argCtl.getScrollWidth();
var root = document.getRootElement();
var cTop = root.getAbsoluteTop();
var cLeft = root.getAbsoluteLeft();

document.getElementById(“confirm_dialog1”).setStyle(“top”, (newTop – cTop) + “px”);
document.getElementById(“confirm_dialog1”).setStyle(“left”, (newLeft – cLeft) + “px”);

First, grab a reference to an object on the page that you wish to position relative to (in this case, I am using a form named “myForm”). Get its x and y coordinates.

Next, get the container x and y by getting its reference (document.getRootElement()) and then its x and y values (getAbsoluteTop and getAbsoluteLeft).

Finally, to accurately position a dialog where an element exists, take the difference between the container and the element being positioned:

document.getElementById(“confirm_dialog1”).setStyle(“top”, (newTop – cTop) + “px”);
document.getElementById(“confirm_dialog1”).setStyle(“left”, (newLeft – cLeft) + “px”);

Voila. You’ve just positioned a dialog over an element.

In practice, you would want some arbitrary additional offset from the control so that you don’t hide it when you pop up / display your dialog. I’ll leave that as an exercise for the reader.

When a Standard Isn’t

When a Standard Isn’t

Since I’ve been in full bore “old fart” mode for the past week or so, I may as well get this gem off my chest to cap off the week.

A recurring theme this week for me, professionally and personally, is the use (or misuse / misappropriation) of the meaning of words.

Take Standards. I wrote a post earlier today about “the emerging standard of OpenSocial” (emphasis mine). A standard is usually one thing by which some other thing is measured. Since there is an absolute dearth of any applications supporting OpenSocial, how can it be called an emerging “standard?” Hell – it doesn’t even purport to be a specification. At the very most optimistic is a very strongly worded letter with very strong recommendations as to what should be supported – but you can define any extensions you like. What the hell is “standard” about that?

Out here in the wilds of the World Wide Web, people bandy about “standards” as if they are passed down on high, when by and large standards are the most flimsiest of figments of the imagination.

Don’t believe me?

In reality, most “standards” come about because someone is first to crack an idea or concept, make it wildly popular, and everyone follows a “compatibility” formula to success. It is only after the market leader has been established that someone comes along behind, codifies what is in fact a fait accompli, and declares a “standard” now in place. Rarely has it worked the other way around, where someone publishes a document, calls it a “standard” and a successful market spring up around it.

I can think of a set of successful “standards” documents that arguably worked this way: the Q’uran, the Bible, and the Torah – but they are entirely outside the scope of this discussion.

I can cite several early technology examples: the IBM PC compatible (possible because IBM published the ROM code and opened the door to the wild success of PC compatible systems); the Hayes Modem AT command set, which revolutionized the ability of PC software to control modems of any make or manufacture as long as they could recognize the Hayes AT command set; the SoundBlaster audio card and command set, which allowed anyone who could communicate with SoundBlaster’s original code set to talk to anyone else’s SB compatible plug in cards.

This is just a handful of the pioneers who were wildly successful, created the “standard” first, and then had it codified by the marketplace. Again, the emphasis is mine.

Even in the web world, though there exist many so called “standards”, all of the successful ones came about as a result of one company dominating (for a time) and everyone else following behind and calcifying a “canon.” Netscape (plus their extenstions) for HTML; 3COM and Ethernet; Internet Explorer and DOM and XMLHTTPRequest (“Ajax” to many of you); with very few exceptions, the “standard” always recognized the de facto market leader, and THEN became codified canon.

Working code is always the coin of the realm.

If we all had to wait around for specification bodies to waive their hands and declare what standards we’d all use nothing would ever get done. Perfect is the enemy of the good.

I had a conversation with a new Facebook contact yesterday and he was talking about how things would get so much better for communication across social networks once social networking “standards” equivalents like XHTML and Acid were adopted. I reminded him that having a standard like XHTML and Acid codified did not force anybody to use them. How many websites follow XHTML? Far too few. How many browsers are fully Acid compliant? You could count them on one hand and 99 out of 100 people don’t use them.

First movers who capture the market set the standard. Twitter isn’t the best designed site, it’s not the prettiest. But they were first out the gate to capture lightning in a jar and it would damn near take a stroke of timing and luck to knock it out of position merely on the basis of looks, speed, and technical merit. The market has spoken, for good or ill.

So, the next time someone starts yammering about the OpenSource “standard” API, be polite. Smile. Nod. If you’re from the South, think “Bless their heart.”

The market always dictates the standard, not the other way around.

This old fart is now going back into his house and you kids can get your ball out of my yard before I call the cops.

Social Networking Applications – Focus and Commitment

Social Networking Applications – Focus and Commitment

Bear with me as I flesh this out.

One observation I have made over the past few years as a “sports parent” is that a child’s level of participation and focus to a team is generally tied to the level of financial commitment to the sport they are engaged in. This is one of those no-brainer, “no shit sherlock” observations – but noteworthy, nonetheless.

For example, the kids on my son’s travel hockey team can pretty much run their own practices with very little guidance. They are punctual (ice time around Nashville runs about $175 an hour for a rink, so if you miss your slot – tough), attentive, and motivated. Compared to my son’s soccer teams, which is very much the epitome of herding cats, the hockey practices are efficient and economical in movement and time management.

The financial investment as a hockey player in equipment is steep when compared with other youth sports. Worse if you happen to be the parent of a goalie (which my youngest son is sadly showing an aptitude for, being the human backstop for my 8 year old). So, if you have a son or daughter playing house league, at a minimum you’re looking at between $500 and $750 in fees and equipment for a season; double that if you also play on a travel team, plus associated travel costs, hotels, food, etc. In short, before too long one can begin to spend real money to watch a bunch of eight year olds skate.

Soccer – a pair of shorts, shirt, shin guards, and cleats – has a relatively low barrier of entry allowing participation to the most casual of participants. This is not a knock of soccer, BTW. In fact, it is surprising that soccer has not advanced more in the US above the high school level given its accessibility and affordability, though travel soccer is just as time and resource consuming as other travel team sports. But my GENERAL observation is that, because of the low barrier of entry, focus and attention to the tasks at hand is extremely lacking. Pretty much anyone who can kick a ball can coach a soccer team. Again, not a knock, a plus in gaining participations across a wide swath of the community.

But this low barrier to entry, relative de-emphasis of skills, and poor coaching talent pool has kept the sport back in the country… while youth ice hockey is beginning to gain momentum in non-traditional sports markets, and is sustaining this level into the minors and college level play. As a prime example, the Nashville Predators (my local NHL team) just drafted its first player “locally grown” last year.

The difference in how poorly soccer has done in capturing the attention of the US sports market – compared to the world, and compared to sports like youth ice – and inline – hockey, is that the level of financial and time commitment to the sport in order to achieve a high level of play.

If one is serious about becoming a better hockey player, you’re probably also taking additional skating lessons outside of regular hockey practices. Lessons usually run around a dollar minute for a good power skating coach, and usually a good session runs 20-30 minutes in length. My eight year old skates a couple of lessons a week outside of hockey practice, and usually cuts this down to a single maintenance skate session per week in the “off season.”

In all, my eight year old son is on the ice about 7-8 hours a week during regular game weeks. Minimum. He has been skating since he was four. My 2 1/2 year old just started lessons this past month.

Am I writing these things to be on that show on Bravo about Uber-Stage parents?

No – I’m writing this to show that in order to achieve a high level of participation in any endeavor (sports, business, personal relationships) it takes sacrifice of self, time, and prolonged focus.

Low barrier to entry only means that more people can participate, not that the quality of play will improve because of the law of large numbers.

In relation to social networking, the low barrier to entry to writing Facebook applications has led to an explosion of some 17,000 or so Facebook applications. Most of them, including some of mine, are less than shall we say noteworthy. Why? Because the level of financial investment in order to be a player is so low that participation is “throw away”, and the consequences of walking away are negligible. There is no real commitment needed to play.

I believe that in order to sustain a viable business social networking environment, a higher bar of entry will be needed to insure focus, commitment, and high quality of engagement. If we are forced to sacrifice and have a little pain in order to participate, I believe we will find our attention to detail will improve, our commitment to reliable uptime will improve, and the level of overall quality of service will improve.

Or, we can continue to find anyone who can write a PHP script as our social media “expert” for the day. That, or find someone who can kick a ball.

Absolutes and Relatives

Absolutes and Relatives

Often as a sports fan, I can make the most ridiculous of assessments.

‘That guy is worthless!”… “You suck!”… “That guy is awesome!”

What I am really saying, or at least what is implied by what I am saying, is that relative to the other players on the field at the time, “that guy is worthless”… relative to the other players on the field at the time, “you suck!”… and relative to the other players on the field at the time, “that guy is awesome!”

We are all guilty of such imprecision, to the disservice of those we dis and those we praise. Even the most lowly of professional athletes are deserving or respect, for where they got in the game. They have met a minimum requirement to “get into the bigs”, beyond the ken of most of us mortals with much less talents and abilities.

This post is not in praise of professional athletics as a profession above all others, but rather, a recognition that when we become accustomed to a high level of performance from our entertainers, our co-workers, or family, our friends – we sometimes heap scorn (and praise) around with little regard for the absolute meaning of what it is we are really saying.

Because, relatively speaking, there stands the smallest of differences between success and failure; between the profane and the sublime.

There is a line in the movie Bull Durham where Kevin Costner is talking about the difference between loitering in the Minor Leagues forever versus making it to “The Show” being “just one more hit, one more ground ball with eyes.”

We all live precipitously on the edge of outstanding success and ignominious anonymity. Chance, preparedness, fortune, luck, talent, timing, the Universe – all of these, maybe none of these – separate the Great from the Rabble.

I was reading a post this morning about whether Web 2.0 was Repeating or Reforming from the excesses and mistakes from Web 1.0 – and this is really what got me thinking about Absolutes, Relatives, and how we don’t differentiate between the two when making assessments of successes and failures, in business and in our personal dealings.

Were the folks at WebVan really that less intelligent than those at Digg, Pownce, and Twitter? I mean, at least WebVan CHARGED something and could nominally be called a “business” (that is, they existed to accept money for goods and services).

Were the wonder boys at Google really that much smarter than Jerry Wang? Was Bill Gates really that much smarter than Steve Jobs, or was Steve Jobs really that much smarter than Bill Gates (don’t laugh – the answer would be different depending upon whether you asked that question in 1993 or in 2003).

We must be careful in our assessments of absolute good, when in fact what we are assessing is relative to the life and times of the present. Our praise of social networking and Web 2.0 must be carefully assessed in light of the times in which these tools and services exist, and carefully examined against the harsh absolutes of business.

Namely, at some point, the check will come due and someone will have to pay the bill.

That is not a relative assessment. That is an absolute fact.