HTML5 Viewer SDK API Documentation 

Namespaces


Class Index

Classes in s7sdk.common

Class s7sdk.common.CloseButton


Extends s7sdk.common.Button.

The CloseButton is used to close the viewer's browser window when the window is opened using JavaScript.

This component does not currently read any modifiers.

Defining the Appearance using CSS

The CSS class for styling the CloseButton is .s7closebutton. This button has four states: up, over, down and disabled. You can style these states by adding the state attribute selector to the CSS class. It is recommended that you define common CSS under the main class and only define the necessary distinctions when using attribute selectors.

CSS ClassAttribute SelectorDescription
.s7closebuttonstate=[up|over|down|disabled]Define the appearance of CloseButton for the various states.
.s7tooltip(None)A global class selector that defines appearance for the tooltips. To disable tooltips set the display style to none.

Localized Symbols

CloseButton also has text symbols that you can localize either in a preset or in the viewer page though the mechanisms provided by the ParameterManager. For more information on localization consult the ParameterManager API documentation and HTML5 Viewers SDK User Guide.

SymbolDescription
CloseButton.TOOLTIPDefine a localized tooltip of CloseButton

Class Summary
Constructor Attributes Constructor Name and Description
 
s7sdk.common.CloseButton(container, settings, compId)
Methods borrowed from class s7sdk.common.Button:
activate, addEventListener, blur, deactivate, dispose, focus, getHeight, getWidth, resize, setCSS
Class Detail
s7sdk.common.CloseButton(container, settings, compId)
Example Code

This example demonstrates how to use the CloseButton component in a simple viewer. In this example a Container object, a ZoomView object, and a CloseButtonButton object are created. Clicking the close button closes the Web browser window which contains the viewer. The code below does the following:

  1. The Scene7 HTML5 SDK is linked to the page and the required s7sdk components are included in the document head.
  2. CSS Styles are defined in the document head to control the appearance of the ZoomView and CloseButton components.
  3. The s7sdk.Util.init() method is called to initialize the SDK.
  4. A ParameterManager object is created to handle component modifiers for the viewer.
  5. An initViewer() function is defined. This function initializes a couple of modifiers (hard coded for example purposes), then creates the component objects required for this simple example. The initViewer() function also adds event listeners that designate functions to handle relevant component events (which might be dispatched by the components as a result of user interactions, changes in a component's state, etc.).
  6. A handler function is defined to respond to the component event listener added in the initViewer() function.
  7. An event listener is added to the ParameterManager object that designates the initViewer() function as the handler to call when the Scene7 SDK is loaded and ready.
  8. Finally, the init() method is called on the ParameterManager object to start the viewer.
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="user-scalable=no, height=device-height, width=device-width, initial-scale=1.0"/> <title>Close Button Example</title> <!-- To run this example locally you need to replace this with an absolute SDK path. For more information check the HTML5 Viewers SDK User Guide or the examples included in the package. --> <script language="javascript" type="text/javascript" src="../js/s7sdk/utils/Utils.js"></script> <script language="javascript" type="text/javascript"> s7sdk.Util.lib.include('s7sdk.common.Container'); s7sdk.Util.lib.include('s7sdk.common.Button'); s7sdk.Util.lib.include('s7sdk.image.ZoomView'); </script> <style type="text/css" media="screen"> .s7zoomview { top: 0px; left: 0px; height: 400px; width: 280px; } .s7closebutton{ position: absolute; top: 0px; left: 280px; width: 30px; height: 30px; } </style> </head> <body> <script language="JavaScript" type="text/javascript"> var params, container, zoomView, closeButton; // Initialize the SDK s7sdk.Util.init(); // Create a ParameterManager instance to handles modifiers params = new s7sdk.ParameterManager(); // Define the function that initializes the viewer function initViewer(){ // Set hardcoded modifiers (not required when values are specified on the url) params.push("serverurl", "http://s7d1.scene7.com/is/image"); params.push("asset", "demo/bedroom.tif"); // Create the viewer Container component object container = new s7sdk.Container(null, params, "s7container"); // Create ZoomView component object zoomView = new s7sdk.image.ZoomView(container, params, "zoomView"); // Create CloseButton component object closeButton = new s7sdk.CloseButton(container, params, "closeBtn"); // Add event listener for closeButton click events closeButton.addEventListener("click", onCloseContainer); } // Define an event handler function to close the window when the user clicks the close button function onCloseContainer(event){ try{ if(s7sdk.browser.name != "firefox"){ //workaround for close self window with JS window.open("s7sdkclose.html","_self"); }else{ // Firefox does not allow the workaround so we fall back to window.close to cover this pop-up case // Note: If dom.allow_scripts_to_close_windows is not set to true in Firefox settings this cannot work. window.close(); } }catch(e){ s7sdk.Logger.log(s7sdk.Logger.WARN, "Cannot close the window"); } } // The ParameterManager will dispatch SDK_READY when all modifiers have been processed // and it is safe to initialize the viewer params.addEventListener(s7sdk.Event.SDK_READY, initViewer, false); // Now it is safe to process the modifiers, the callbacks have been defined // this will trigger the SDK_READY event params.init(); </script> </body> </html>
Default styles for CloseButton:

.s7closebutton {
	width:32px;
	height:32px;
	background-size:contain;
	background-repeat:no-repeat;
	background-position:center;
	-webkit-touch-callout:none;
	-webkit-user-select:none;
	-moz-user-select:none;
	-ms-user-select:none;
	user-select:none;
	-webkit-tap-highlight-color:rgba(0,0,0,0);
 }
.s7closebutton[state='up'] {
	background-image:url(images/sdk/close_up.png);
 }
.s7closebutton[state='over'] {
	background-image:url(images/sdk/close_over.png);
 }
.s7closebutton[state='down'] {
	background-image:url(images/sdk/close_down.png);
 }
.s7closebutton[state='disabled'] {
	background-image:url(images/sdk/close_disabled.png);
 }
.s7tooltip {
	position:absolute;
	padding:5px;
	line-height:100%;
	text-align:center;
	background-color:rgb(224, 224, 224);
	color:rgb(26,26,26);
	font-family:Helvetica, sans-serif;
	font-size:11px;
	z-index:10000;
	border:1px solid rgb(191,191,191);
 }
Parameters:
{String|Container} container
The reference to Container instance, ControlBar instance or the ID of the parent DOM element to which the component is added as a child
{s7sdk.ParameterManager} settings
ParameterManager as settings.
{String} compId
A unique ID for this component.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Jan 30 2020 16:40:36 GMT+0200 (EET)