Difference between revisions of "Linden Lab Official:Viewer Web Widgets"
Tatva Linden (talk | contribs) |
m (→Future roadmap) |
||
Line 167: | Line 167: | ||
==Future roadmap== | ==Future roadmap== | ||
For other features or requests, please file a Jira in the 'Web' project for component 'Viewer Login Page' and/or discuss in the talk page here. | |||
For other features or requests, please file a Jira and/or discuss in the talk page here. |
Revision as of 03:26, 13 October 2011
Important: Work-in-progress! Expect these widgets to change over time. Watch this page for updates. |
These viewer web widgets are a first attempt at making the current Second Life Viewer login screen features available for easy use in third-party viewers. Linden Lab provides a base Javascript library that searches the DOM of a given page, populating specifically-named divs with widget content.
Basic implementation
The example below shows the simplest way to implement these widgets. Simply include the sl.widgets.js library, then include a div with both id="[the widget you want]" and class="second-life-widget".
<html4strict> <!DOCTYPE html> <html>
<head> <script type="text/javascript" src="http://lecs-viewer-login-agni.s3.amazonaws.com/pubwidgets/v1/modules/sl.widgets.js"> </script> </head> <body>
</body>
</html> </html4strict>
Version 1 of the main sl.widgets.js library currently lives here:
http://lecs-viewer-login-agni.s3.amazonaws.com/pubwidgets/v1/modules/sl.widgets.js
This library will pull in all the supporting content it needs -- other Javascript files, CSS, and the content for each widget. It uses its own version of jQuery, and will create a separate namespace to avoid conflicts if you already have jQuery installed.
Widgets
Widget Options
Each widget has 2 configuration options that can be passed to it.
- The number of items a particular widget can have.
- The callback javascript function that needs to be called when someone clicks the particular event/item inside the widget.
All configuration is passed to widgets through a global javascript variable called - slconfig. It's a javascript object which further contains individual configuration object for each widget. Below is an example of setting some options to what's what now widget.
<html4strict> <script type="text/javascript">
var slconfig = {}; slconfig['whatshotnow'] = {
itemsPerPage : 4, onclick: localClick
};
function localClick(stuff){
alert(stuff); return false;
}
</script> </html4strict>
In the above code we do couple of things.
- Define a global javascript object called slconfig.
- Set the config object for what's how not widget. This needs to be called 'whatshotnow'. For other widgets please refer below sections.
- We also set onclick functionality. We are setting it to a localClick function which is defined later in the code. Please make sure you don't add () next to the function name as it would result in calling the function which we don't want. We just need to set the function name.
- The local function gets passed slurl of the event or destination.
Widget Size Precedence
- Items per page
- Width defined in css
When items per page is passed, the widget resizes to fit those number of items. It won't take into consideration whether the widget fits the container or not. When the items per page isn't passed - the size of the widgets is taken from the css file. This again has an order. By default all widgets use Second Life widgets css, and can be over-ridden by your local css file or inline css.
What's hot now
This widget displays a thumbnail list of destinations with people (a population of 25 or less, in the last ~10 minutes). The cutoff number may change over time; 25 was chosen as a reasonable performance threshold.
With the main js library loaded, include this div in your html markup:
<div id="whats-hot-now-widget" class="second-life-widget"></div>
This widget expects the above div to be a fixed height of 148px. It will adapt its content to 100% of the div's width, so you can make it as wide as you like. To control positioning, size, and other parameters, just style the #whats-hot-now-widget in your own page's CSS.
This widget takes 2 options. It needs to be set in slconfig['whatshotnow'] object. Below are the options.
- itemsPerPage - the number of items in the widget per page.
- onclick - a javascript function which needs to be called when an item in this widget gets clicked. The javascript function is called back with the clicked item slurl. When this option is set, the overlay which usually shows up is cancelled.
Destinations
This widget displays a thumbnail list of destinations from a category. The default category is 'Featured Events'. It can be changed from the select box in the widget. The maximum number of destinations shown is 24.
With the main js library loaded, include this div in your html markup:
<div id="destinations-widget" class="second-life-widget"></div>
This widget expects the above div to be a fixed height of 148px. It will adapt its content to 100% of the div's width, so you can make it as wide as you like. To control positioning, size, and other parameters, just style the #destinations-widget in your own page's CSS.
This widget takes 2 options. It needs to be set in slconfig['destinations'] object. Below are the options.
- itemsPerPage - the number of items in the widget per page.
- onclick - a javascript function which needs to be called when an item in this widget gets clicked. The javascript function is called back with the clicked item slurl. When this option is set, the overlay which usually shows up is cancelled.
Blogs
This widget displays a list of all recent blog posts from SL.
With the main js library loaded, include this div in your html markup:
<div id="blogs-widget" class="second-life-widget"></div>
This widget expects the above div to be a fixed width of 263px. The height will change based on the css/itemsPerPage options. To control positioning, size, and other parameters, just style the #blogs-widget in your own page's CSS.
This widget takes 2 options. It needs to be set in slconfig['blog'] object. Below are the options.
- itemsPerPage - the number of blog listings in the widget per page.
- onclick - a javascript function which needs to be called when an item in this widget gets clicked. The javascript function is called back with an object. When this option is set, the overlay which usually shows up is cancelled. Here is what is passed back to the call back - a object with these properties - creator, date, description, link, pubDate, title
Destination Images
This widget displays a scrollable list of featured destinations with larger pictures. The number of destinations shown is 8.
With the main js library loaded, include this div in your html markup:
<div id="destination-images-widget" class="second-life-widget"></div>
This widget expects the above div to be a fixed height of 267px and fixed width of 660px. To control positioning, and other parameters, just style the #destination-widget in your own page's CSS.
This widget takes 1 options. It needs to be set in slconfig['destination-images'] object. Below are the options.
- onclick - a javascript function which needs to be called when an item in this widget gets clicked. The javascript function is called back with the clicked item slurl. When this option is set, the overlay which usually shows up is cancelled.
Upcoming Events (List Version)
This widget displays a list of upcoming events sorted with the most recent one at top
With the main js library loaded, include this div in your html markup:
<div id="upcoming-events-widget" class="second-life-widget"></div>
This widget expects the above div to be a fixed width of 263px. It will adapt its content to 100% of the div's width, so you can make it as wide as you like. To control positioning, size, and other parameters, just style the #upcoming-events-widget in your own page's CSS.
This widget takes 2 options. It needs to be set in slconfig['events'] object. Below are the options.
- itemsPerPage - the number of items in the widget per page.
- onclick - a javascript function which needs to be called when an item in this widget gets clicked. The javascript function is called back with the clicked item slurl. When this option is set, the overlay which usually shows up is cancelled.
Upcoming Events (Filmstrip Version)
This widget displays thumbnail list of upcoming events sorted with the most recent one at the beginning
With the main js library loaded, include this div in your html markup:
<div id="events-fs-widget" class="second-life-widget"></div>
This widget expects the above div to be a fixed height of 143px. It will adapt its content to 100% of the div's width, so you can make it as wide as you like. To control positioning, size, and other parameters, just style the #upcoming-events-widget in your own page's CSS.
This widget takes 2 options. It needs to be set in slconfig['eventsfs'] object. Below are the options.
- itemsPerPage - the number of items in the widget per page.
- onclick - a javascript function which needs to be called when an item in this widget gets clicked. The javascript function is called back with the clicked item slurl. When this option is set, the overlay which usually shows up is cancelled.
Localization
Widget strings can be localized by adding ?lang=[de|es|fr|ja|pt] to your page's URL.
Future roadmap
For other features or requests, please file a Jira in the 'Web' project for component 'Viewer Login Page' and/or discuss in the talk page here.