initializationState = FBInitialization.InitializationState.Initialized;
fireInitSuccess();
return;
}
Document doc = Document.get();
Element fbRootElement = doc.getElementById(FacebookRootElementID);
if (fbRootElement == null) {
fbRootElement = DOM.createDiv();
fbRootElement.setId(FacebookRootElementID);
BodyElement bodyElement = doc.getBody();
bodyElement.appendChild(fbRootElement);
}
String fbLocale = locale;
if (fbLocale == null) {
// todo: get default locale from user, accounting for list of Facebook-allowed locales, available from http://www.facebook.com/translations/FacebookLocales.xml
fbLocale = DefaultLocale;
}
ScriptElement script = doc.createScriptElement();
script.setType("text/javascript");
script.setId(FacebookScriptElementID);
script.setSrc(Window.Location.getProtocol() + "//" + FacebookScriptServer + "/" + fbLocale + "/" + FacebookScriptName);
// facebook seems to think this async is necessary
script.setPropertyBoolean("async", true);