Orkut lança largura variável para a visão canvas
Saiu uma notícia importante na opensocial-orkut. Até então, os aplicativos não possibilitavam configuração da largura variável. Depois de alguns membros solicitarem tal funcionalidade, o Orkut implementou e lançou. Além disso, duas novas flag estão disponíveis: containerVersion e gadgetWidth. Ex:
gadgets.utils.getUrlParameters()["containerVersion"]; ou
gadgets.utils.getUrlParameters()["gadgetWidth"];
Post complexo (em inglês) - ver thread:
We now support two cool new features for gadgets in canvas view:
- Container version detection
- Flexible application width
A quick introduction follows. We hope you enjoy them! They're enabled on sandbox and should reach production soon. If you have any feedback, please let us know!
Container Version Detection
The Container Version is supplied to your gadget in a new iframe parameter (containerVersion) in canvas view, so it can be retrieved like this:
var containerVersion = gadgets.util.getUrlParameters()["containerVersion"];
Its value is 1 for the canvas view container in the old orkut UI and 2 for the canvas view container in the new orkut UI. You can read this to determine which container your application is running inside of. Please be aware, however, that "container version" is not the same as "orkut UI version"... for now, there is a 1-to-1 correspondence (1 for old orkut, 2 for new orkut) but this may come out of sync when we launch new container versions or new UIs.
Configurable App Width
That's right, we now support configurable width for applications in canvas view!
You can specify a "preferred width" to orkut in your applications XML by means of the preferred_width attribute of the Content tag:
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Yourtitlehere"
author="authorhere"
author_email="email_here@......com"
description="Description here...."
screenshot="http://url/of/a/screenshot/of/your/app"
thumbnail="http://url/of/the/thumbnail/for/your/app">
<Require feature="opensocial-0.8" />
<Locale lang="en" country="us" />
</ModulePrefs>
<Content type="html" preferred_width="900">
<![CDATA[
...
</Content>
</Module>
The container will try to allocate your indicated width but might have to crop it if it's too big and expand it if it's too small. The actual width will be reported to you in the "gadgetWidth" iframe parameter.
Some points to take into account are:
- The preferred_width parameter will only be taken into account when rendering your application on container version 2, but will be ignored in container version 1.
- The container might or might not honor your preferred width depending on the available space.
- The gadgetWidth iframe parameter is only available to your application in container version 2 and above. This is the "slight catch" we were talking about above.
Therefore, the correct way to determine your application's actual width is first testing the container version and then, if the version is 2 or above, reading the gadgetWidth parameter. Otherwise (container version 1), the width of the gadget is fixed at 835px. So an example of Javascript code would be:
// Determines the actual width of the application
function getActualWidth() {
return (gadgets.util.getUrlParameters()["containerVersion"] >= 2) ?
gadgets.util.getUrlParameters()["gadgetWidth"] : 835;
}
Projeto
Categorias
- Bibliotecas para orkut (3)
- Opensocial com flash (1)
- Opensocial com PHP (2)
- Orkut (17)
- Palestras e eventos (2)
- Segurança de aplicativos (2)
- Shindig (2)
- Signed Request (2)
- Uncategorized (1)