Jacob
posted this on August 31, 2011 15:14
The Vizit™ Client Library is a javascript API for configuring and working with Vizit Essential™ and buttons in Document Libraries in SharePoint.
Object Model: http://files.vizit.com/public/docs/
4.0 Object Model: http://files.vizit.com/public/docs/4.0/
In the documentation, you'll find 3 different ways to integrate with Vizit Essential™ and those buttons: Vizit.Write, VIZIT_SETTINGS, and the Vizit namespace.
Vizit.Write is replacing link decoration in version 4.1 of Vizit™. To provide better performance, Vizit™ no longer crawls the page to find links where Vizit™ should be applied. Instead, Vizit.Write can be called to place buttons, instant previews, and links to documents that open in Vizit Essential™ on the page as it is rendered. Vizit.Write is the simplest way to open documents in Vizit Essential™. Here are two example links that use this functionality:
// This example will write the configured buttons to the page for the document URL provided.
Vizit.Write("http://path/to/file.ext");
// This example will write a link to the page. Clicking the link will open the document in Vizit Essential™.
// Any configured buttons will be displayed next to the link as well.
Vizit.Write("http://path/to/file.ext", "Click Here");
// If no buttons were configured for the page, the globally defined defaults will be used.
// This example will write an instant preview to the page regardless of the
// globally configured or globally defined VIZIT_SETTINGS.
Vizit.Write("http://path/to/file.ext", { buttons: [ "InstantPreview" ] });
By placing a VIZIT_SETTINGS JavaScript object on the page, you can configure the size and position of the Vizit Essential™ window, what actions are available in the toolbar, any keyboard actions, as well as many other options. You can also configure which buttons appear next to document links in document libraries and whether or not Instant Previews are shown on a given page. VIZIT_SETTINGS provides much of the power found in the full Vizit™ JavaScript namespace in a simple package.
Here's an example of how to use VIZIT_SETTINGS to specify the buttons that should appear next to document links on the SharePoint page, the width and height of Vizit Essential™, as well as a specific set of actions that should appear in the toolbar. Any configuration options that are not specified have a default that can be found in the documentation. Because of this, all the default keyboard actions will continue to work as expected.
var VIZIT_SETTINGS = {
buttons: [ 'OpenInEssential' ],
width: 400,
height: 300,
actions: [
'PrevPage',
'NextPage',
'FullScreen'
]
};
VIZIT_SETTINGS is effectively a combination of configuration parameters from Vizit.Essential.Controller and buttons: 'OpenInEssential', 'OpenInPro', and 'InstantPreview'.
Links that open a document in Vizit can be created by adding #vizit to the end of the URL. For example:
<a href="http://path/to/file.ext#vizit">Click Here</a>
The Vizit JavaScript namespace provides full access to Vizit Essential™ and the buttons including a full eventing model and other utilities. One way this could be used would be to programmatically control Vizit Essential™'s behavior from outside of the main Vizit Essential™ window and toolbar.
<div id="viewer" style="width:500px; height:400px;"></div>
<img src="path/to/icon.png" onclick="MyNamespace.Viewer.PreviousPage();" />
<img src="path/to/icon2.png" onclick="MyNamespace.Viewer.NextPage();" />
<script type="text/javascript">
var MyNamespace = {};
Vizit.OnReady(function() {
var controller = new Vizit.Essential.Controller({
renderTo: 'viewer'
});
MyNamespace.Viewer = controller.GetDocumentPanel();
});
</script>
Any delegates passed to Vizit.OnReady will be called as soon as the Vizit Client Library is fully loaded on the page and any required resources are available. If Vizit™ is ready when the delegate is passed to Vizit.OnReady, the delegate will be called immediately. It is because of this, that we recommend you wrap any initialization code inside a Vizit.OnReady delegate to ensure that Vizit™ is available when calls to the client library are made.