|
|
On-Page APILaunchpad On-Page is a standalone viral sharing menu that you can place anywhere on your site. It allows users to post, email or bookmark your widget to their destination of choice with a simple and intuitive interface. They can also grab your embed code, too! You include the menu using some simple Javascript code. You can share any arbitrary piece of content you want, or you share widgets that are registered with the Clearspring platform. This guide provides detailed information on the Javascript API, and all of the different options for customizing the UI. If you're looking for basic info on what Launchpad On-Page is and where to get pre-built code, check out the following topics:
Table of Contents
Menus and buttonsThe Launchpad tools come in two different visual flavors: a full menu, or a button that pops up a menu. The menu looks like this: The button is a good choice when you want to take up just a small amount of space on your page -- it is as functional as the full menu, it just doesn't display until the user clicks it. It looks like this (go ahead, click on it!): Including the APIInclude the Launchpad API in your page with the following code:<script src="http://widgets.clearspring.com/launchpad/include.js" type="text/javascript"></script> You must include this code before you make a call to any Launchpad Javascript functions. It only needs to go in the page once, and it does not need to be in the HTML head. Note: In order for Launchpd to properly position itself on your page, you should make sure you are setting a DOCTYPE for your page. This is a best practice, though not always required in general. The DOCTYPE declaration at the top of your page might look like the following, for XHTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" Launchpad Javascript functionsThe primary Launchpad Javascript functions are:
Calling the functions: dynamic and pre-registered widgetsTo call any of the three primary Javascript functions, you pass a single argument: a Javascript object with certain required and optional names and values (JSON format). There are two basic ways to call the functions, and a set of options that are common to both:
Creating menus to share widgets dynamically
You can create a widget on-the-fly by specifying an arbitrary blob of content and passing it to the functions. You do this by identifying a HTML element, like a textarea, that contains your blob and passing the ID of this element (or a pointer to the element if you really want), into the function via the <textarea id="myCode" > You can get your user ID (as well as the rest of this code pre-built for you), by visiting clearspring.com/services/launchpad/on-page. Note: if you have a Flash blob it may not appear on some destinations. This is due to your domain not being whitelisted by the service. Please contact the service to be added to their whitelist. All of the options relevant to these dynamically-registered widgets are listed in the following table:
A Note on dynamic content: Remember that whatever the state of your content is in the DOM at the time you share will be the content that is posted to the server. In other words, if you are including Javascript that self-modifies the content of your page, and that executes before the user shares, then the modified content will be what is actually shared. It will NOT be the original content in your page source. Creating menus to share pre-registered widgets
You need to pass the ID of your registered widget in a var options = {};
...or just something like this:
$Launchpad.ShowMenu({wid: "465db8f226724744"});
Note that you can get a call like this pre-built for you for a particular widget, by going to the Share It -> Launchpad tool in the Widget Console. All of the options relevant to pre-registered widgets are listed in the following table:
Shared optionsThe following table lists options that are common to both kinds of calls:
Available Service IdentifiersThe set of possible service identifiers, for use in the various Launchpad On-Page Javascript calls, is:
Note that if you use the service type name, like 'post', rather than an individual service, you can enable or disable whole tabs of services at once. Menu object methods
Each of the primary Javascript functions actually returns a
Note: If using these methods, the best practice is to also specify the Basic usage examplesThe following sections provide some general example calls. Also check out the Guides section for additional documentation on using and configuring Launchpad On-Page.Specifying configuration for registered widgetsIf you have a registered widget that uses the Clearspring configuration system, you can use theconfig option to tell Launchpad to share a specific configuration of the widget. Specify arguments like this:
config : { "feed" : "http://www.example.com/rss.xml", "title" : "Latest updates" }
This will set a parameter <script type="text/javascript"> Note that you cannot use this argument when sharing an dynamically-registered widget; these are not managed by the platform (other than for analytics data), and therefore don't use the configuration system. Controlling available servicesYou can configure the menu to enable or disable certain viral services. For example, to enable MySpace, Facebook, and Email sharing, make the call like this: servicesInclude : [ 'myspace', 'facebook', 'email' ] To exclude certain viral services use code like this: servicesExclude : [ 'myspace', 'facebook', 'email' ] The full list of service identifiers is here. Note that if you disable certain services, the Post, Bookmark, Email, etc tabs at the top of the menu will disable automatically. Further, if you select only one service, the menu will automatically go right to that service's interface, without requiring a use to press a button. For example, specifying only MySpace, the menu would look like this: This can be useful for creating buttons for individual services, if you'd like. For more information on configuring services check out the "Configuring the serivces on Launchpad On-Page" guide. Specifying different content for different services
Not all destinations can accept the same code -- some sites do not allow Javascript, for example, while others do. When creating widgets on the fly, you can pass multiple different service-specific chunks of content in the <script type="text/javascript">
Coupled with using Including your widget and the Launchpad On-Page menu on the same pageFor registered widgets, as you know, Clearspring can add a Get & Share menu to the bottom of your widget automatically. This allows users to easily get a copy of your widget for themselves. If you'd like to build the seeding page on your site to have both your widget and the Launchpad On-Page sharing menu, you might want to make sure that the Get & Share dock doesn't display. If it did, you would be giving users two ways to grab the widget, and it may be confusing. You can use the Share It -> Get the code tool in the Widget Console to get the code you need to embed your widget on your site, properly configured. If you want to disable the Get & Share menu on an instance of your widget manually, you can pass a special Doing this will prevent the dock from showing up on your widget when its on your seeding page, displayed from this URL, but it will still display once the widget is shared out to other locations.
Wherever the Clearspring widget URL appears in the generated code for your widget, just modify it to pass the -DBL value in the standard way, like this: http://widgets.clearspring.com/o/WID/PID/-/-/-DBL/0/or http://widgets.clearspring.com/o/WID/PID/-/-/-DBL/0/widget.js You may need to make this change in two locations, depending on whether you are using HTML embed code or Javascript code. In either case, the URL will appear the same. For more information on overriding configuration parameters, see the documentation on Overriding Parameters and on Widget URL Format. This special parameter is not discussed there, but is passed using the same general scheme. Customizing the Appearance of your MenuThe Launchpad menu can be themed in a variety of ways, allowing you to make a completely custom look and feel that integrates well with the rest of your site. For more information on customization options check out "Customizing the Launchpad On-Page Menu Guide". Using your own buttonYou don't have to use any of our buttons if you don't want to. If you want to pop up the menu from a link, from your own button, or wherever, you can use theCreateMenu function to do so. The function lets you create a menu object, using the same arguments available to ShowMenu and ShowButton, attached to any arbitrary element on your page. This will make a menu that looks and acts like any other Launchpad menu, but it will not be initially visible. The menu will be automatically displayed whenever the user clicks the element you provided. So, you can make any image, text link, or anything else into a trigger for the menu!
For example, to attach a menu to a simple text link, and have it display when the link is clicked, you could do this: <a id="myLink" href="#">My link</a> This code in action would look like this: My link
The
Note: You should include the Feel free to use the following button images with
To use one of the buttons above you could do this: <a id="csBtn" href="#"><img id="button-fav" src="http://cdn.clearspring.com/launchpad/static/cs_button_share1.gif" alt="" /></a>
This code in action would look like this: Using CSS to build a custom theme for your menuYou can specify a cascading stylesheet (CSS) of your own, and feed it into the Launchpad menu (using the NOTE: You must specify a valid URL for this parameter -- if you specify an invalid URL, the menu will not appear correctly. To use this feature, just add any simple style changes you'd like into a new stylesheet, set the CSS parameter, and your styles will combine with the default style. So, to change the color scheme, you could use code like this to point to your own stylesheet: <script type="text/javascript"> Within the stylesheet, you would just add the background color styling like this: /* Main Background */ A commented example stylesheet is available here, if you want to copy it to your server for your own use. The resulting styled menu will look like this: You override as much of the standard style as you want, even replacing every element with your own custom version. This gives you total control over the menu appearance, and will let you build a complete theme for the menu. For example, the following code will completely restyle the menu using a "black" style: <script type="text/javascript"> This code will render the menu like this: CSS examples & tipsThe easiest way to get familiar with the CSS classes you can modify is to just look at the example stylesheets. Here are a few examples of themes you can use to get started; you can even copy these to your server and just use them directly, if you'd like:
Note: When passing in customized CSS to further personalize your Launchpad, remember to use absolute paths to reference your images and other assets. Clue Us In!If you develop any cool themes that you want to share, or have any questions on building your own themes, let us know in the forums! |

