Class s7sdk.share.EmailShare
Extends
s7sdk.common.Button.
The EmailShare
component allows user to share content via email. It represents a button and an associated modal dialog that appears on the screen
when user clicks or taps on the button. The dialog contains email submission form with one or more "To" input fields, "From" input field and optional user message. In addition
component provides API to specify content URL, content description, content title and origin URL. When user submits the form, the data is being sent to a backend service, which
creates email message and sends it to an addressee(s).
The modal dialog is implemented by a separate EmailDialog
component. EmailShare
creates an instance of EmailDialog
and assigns an instance name
to it by appending "_dialog" to the EmailShare
instance name. EmailDialog
instance is styled using s7emaildialog
CSS class. In order to change styles
of the inner dialog instance setCSS()
should still be called on EmailShare
instance. EmailDialog
is added to the closest parent s7sdk.common.Container
instance in case the application is using s7sdk.common.Container
component or to the document BODY
. Creating a standalone instance of EmailDialog
component is not currently supported.
The following modifiers are supported:
Modifier | Syntax | Description | Default |
serverurl | isRootPath | The Adobe Image Serving root path. If no domain is specified, the domain from which the page is served is applied instead. Standard URI path resolution applies. To render thumbnails properly in outgoing email, the modifier must use an absolute URL. | /is/image/ |
Defining the Appearance using CSS
The CSS class for styling the EmailShare
is .s7emailshare
. This button has the following 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 you use attribute selectors.
CSS Class | Attribute Selector | Description |
.s7emailshare | state=[up|over|down|disabled] | Define the appearance of EmailShare button for each state. |
.s7emaildialog | (None) | Top-level container for the sharing modal dialog. |
.s7backoverlay | (None) | Define the web page shading color and opacity. |
.s7dialog | (None) | Define modal dialog appearance, including border settings and background color. The logic will size and center the dialog automatically according to content, which is the standard behavior on desktops; however if width and height properties are set to 100% the component will always display the dialog in full screen, which is recommended behavior on touch devices. |
.s7dialogheader | (None) | Define the dialog header container. |
.s7dialogheadericon | (None) | Define the dialog icon displayed in the header. |
.s7dialogheadertext | (None) | Define the dialog title displayed in the header. |
.s7dialogfooter | (None) | Define the dialog footer container. |
.s7dialogbuttoncontainer | (None) | Define the container for buttons displayed in the footer. |
.s7button | (None) | Define the common styling for cancel and action buttons in the footer. |
.s7dialogcancelbutton | state=[up|over|down|disabled] | Define the appearance of cancel button in the footer for each state. |
.s7dialogactionbutton | state=[up|over|down|disabled] | Define the appearance of primary action button in the footer for each state. |
.s7dialogviewarea | state=[sendsuccess] | Define the dialog area where the main content is displayed. Optional state attribute selector defines the dialog state; when its value is empty the dialog is in initial state; sendsuccess is set when email was successfully sent or a potential server-side error has occurred. |
.s7dialogbody | (None) | Define the top-level container for dialog content. |
.s7dialoglinefeed | (None) | Utility class which is used for line separator inside dialog content. |
.s7dialogline | (None) | Define the appearance of the top-level container for single dialog line. |
.s7dialoglabel | (None) | Define the appearance of the common label text. |
.s7dialoginputlabel | (None) | Define the appearance of the label text to the left of input control. |
.s7dialoginputcontainer | state=[verifyerror] | Define the top-level container for the input control. Optional state attribute selector is set to verifyerror value in case user input is invalid. |
.s7dialoginputshort | (None) | Define the appearance of "short" input control. |
.s7dialoginputwide | (None) | Define the appearance of normal input control. |
.s7dialogmessage | (None) | Define the appearance of the multi-line input control used for email message. |
.s7dialogcontent | (None) | Define the top level container for content information panel. |
.s7dialogthumbnail | (None) | Define the appearance of the content thumbnail. |
.s7dialoginfopanel | (None) | Define the container for content title, origin URL and description. |
.s7dialogtitle | (None) | Define the appearance of the content title. |
.s7dialogorigin | (None) | Define the appearance of the content origin URL. |
.s7dialogdescription | (None) | Define the appearance of the content description. |
.s7dialogerror | error=[true|false] | Define the top-level container of the error message. The error attribute selector is set to true in case component has hit an error condition. |
.s7dialogerrormessage | state=[verifyerror|senderror|sendsuccess] | Define the appearance of message area. When verifyerror is set the message notifies user about bad input; senderror informs about failure to send an email; sendsuccess confirms that the email was sent successfully. |
.s7closebutton | state=[up|over|down|disabled] | Define the appearance of the close button in the top right corner for each state. |
.s7dialogaddemailbutton | state=[up|over|down|disabled] | Define the appearance of the "add email" button for each state. |
.s7dialogremoveemailbutton | state=[up|over|down|disabled] | Define the appearance of the "remove email" button for each state. |
.s7dialogscrollpanel | (None) | Define the top-level container for optional scroll bar. |
.s7scrollbar | (None) | Define the appearance of the main scroll bar element. |
.s7scrolltrack | (None) | Define the appearance of the scroll track. |
.s7tooltip | (None) | A global class selector that defines appearance for the tooltips. To disable tooltips set the display style to none . |
Localized Symbols
EmailShare
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 Adobe Experience Viewers HTML5 SDK User Guide.
Symbol | Description |
EmailShare.TOOLTIP | Tooltip for EmailShare button. |
EmailShare.HEADER | Dialog header text. |
EmailShare.TOOLTIP_HEADER_CLOSE | Tooltip for the top right close button in modal dialog. |
EmailShare.INVALID_ADDRESSS | Error message displayed in case email address is malformed. |
EmailShare.TO | Label for "To" input field. |
EmailShare.PRIMARY_EMAIL_ADDRESS | Label for primary "To" input field. |
EmailShare.TOOLTIP_ADD | Tooltip for "Add Another Email Address" button. |
EmailShare.ADD | Caption for "Add Another Email Address" button. |
EmailShare.ADDITIONAL_EMAIL_ADDRESS | Label for additional "To" input fields. |
EmailShare.FROM | Label for "From" input field. |
EmailShare.MESSAGE | Label for "Message" input field. |
EmailShare.TOOLTIP_REMOVE | Tooltip for "Remove Email Address" button. |
EmailShare.CANCEL | Caption for "Cancel" button. |
EmailShare.TOOLTIP_CANCEL | Tooltip for "Cancel" button. |
EmailShare.CLOSE | Caption for the close button displayed in the bottom of dialog after form submission. |
EmailShare.TOOLTIP_CLOSE | Tooltip for the close button displayed in the bottom of dialog after form submission. |
EmailShare.ACTION | Caption for form submission button. |
EmailShare.TOOLTIP_ACTION | Tooltip for form submission button. |
EmailShare.SEND_SUCCESS | Confirmation message displayed when email was sent successfully. |
EmailShare.SEND_FAILURE | Error message displayed when email was not sent successfully. |
Constructor Attributes | Constructor Name and Description |
---|---|
s7sdk.share.EmailShare(containerId, settings, compId)
|
Method Attributes | Method Name and Description |
---|---|
addEventListener(type, handler, useCapture)
Adds an event listener to the instance of the
EmailShare component. |
|
setContentTitle(title)
Sets content title to put in email body.
|
|
setContentUrl(contentUrl)
Sets URL to put in email body.
|
|
setCSS(classname, property, value)
Sets a particular CSS class and property on a component
|
|
setDescription(descr)
Sets content description.
|
|
setModifier(modObj)
Sets 1-N # of modifiers for the component.
|
|
setOriginUrl(originURL)
Sets the origin URL for the content (for example the domain name of customer's web site).
|
|
setThumbnail(thumbnail)
Sets content thumbnail in form of company/assetId.
|
- Methods borrowed from class s7sdk.common.Button:
- activate, blur, deactivate, dispose, focus, getHeight, getWidth, resize, setLabel
Example Code
This example demonstrates how to use sharing components in a simple viewer. In this example a ZoomView object,
a SocialShare object, an EmailShare object, a EmbedShare object, a LinkShare object, a TwitterShare
object and a FacebookShare object are created. When a user clicks the SocialShare button, a panel with all sharing components appears.
When a user clicks on individual share component (EmailShare, EmbedShare, LinkShare, TwitterShare or FacebookShare)
corresponding social sharing dialogs popups up. EmailShare, EmbedShare and LinkShare components have their own modal dialogs.
TwitterShare and FacebookShare trigger sharing dialog from corresponding social service.
The code below does the following:
- The Adobe Experience Viewers HTML5 SDK is linked to the page and the required s7sdk components are included in the document head.
- CSS Styles are defined in the document head to control the appearance of the SDK components.
- The s7sdk.Util.init() method is called to initialize the SDK.
- A ParameterManager object is created to handle component modifiers for the viewer.
- 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.).
- Handler functions are defined to respond to the component event listeners added in the initViewer() function.
- An event listener is added to the ParameterManager object that designates the initViewer() function as the handler
to call when the Adobe Experience Viewers HTML5 SDK is loaded and ready.
- Finally, the init() method is called on the ParameterManager object to start the viewer.
<!DOCTYPE html>
<!--
*
* ADOBE SYSTEMS INCORPORATED
* Copyright 2013 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file in
* accordance with the terms of the Adobe license agreement accompanying it.
* If you have received this file from a source other than Adobe, then your
* use, modification, or distribution of it requires the prior written
* permission of Adobe.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>SocialShare Component</title>
<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.Button');
s7sdk.Util.lib.include('s7sdk.image.ZoomView');
s7sdk.Util.lib.include('s7sdk.share.Share');
</script>
<style type="text/css">
.s7zoomview {
width:400px;
height:400px;
}
.s7zoominbutton, .s7zoomoutbutton, .s7zoomresetbutton, .s7socialshare {
position:absolute;
top:410px;
}
.s7zoomoutbutton {
left:30px;
}
.s7zoomresetbutton {
left:60px;
}
.s7socialshare {
left:350px;
}
</style>
</head>
<body>
<div id="s7container" style="position:relative;width:500px;height:500px;"></div>
<script language="JavaScript" type="text/javascript">
s7sdk.Util.init();
var myParams = new s7sdk.ParameterManager(); //Parameter Manager
var zoomComp, zoomResetButton, zoomInButton, zoomOutButton, socialShare, emailShare, linkShare, embedShare, facebookShare, twitterShare;
function initViewer(){
myParams.push("serverurl", "https://s7d1.scene7.com/is/image");
myParams.push("asset", "sample/0");
zoomComp = new s7sdk.ZoomView("s7container", myParams);
zoomResetButton = new s7sdk.ZoomResetButton("s7container", myParams);
zoomInButton = new s7sdk.ZoomInButton("s7container", myParams);
zoomOutButton = new s7sdk.ZoomOutButton("s7container", myParams);
zoomResetButton.addEventListener("click",function(){zoomComp.zoomReset();});
zoomInButton.addEventListener("click",function(){zoomComp.zoomIn();});
zoomOutButton.addEventListener("click",function(){zoomComp.zoomOut();});
socialShare = new s7sdk.share.SocialShare("s7container", myParams, "socialShare");
emailShare = new s7sdk.share.EmailShare("socialShare", myParams);
emailShare.setContentTitle("Content title");
emailShare.setContentUrl("https://www.adobe.com");
emailShare.setDescription("Content description");
emailShare.setOriginUrl("https://www.adobe.com/");
emailShare.setThumbnail("sample/0");
linkShare = new s7sdk.share.LinkShare("socialShare", myParams);
linkShare.setContentUrl("https://www.adobe.com");
embedShare = new s7sdk.share.EmbedShare("socialShare", myParams);
embedShare.setEmbedCode(
"<script language=\"javascript\" type=\"text/javascript\" src=\"https://s7d1.scene7.com/s7viewers/html5/js/BasicZoomViewer.js\"></sc" + "ript>\n" +
"<div id='basiczoom'></div>\n" +
"<script type=\"text/javascript\">\n" +
"var basicZoomViewer = new s7viewers.BasicZoomViewer();\n" +
"basicZoomViewer.setContainerId(\"basiczoom\");\n" +
"basicZoomViewer.setAsset(\"sample/0\");\n" +
"basicZoomViewer.setParam(\"stagesize\",\"$EMBED_WIDTH$,$EMBED_HEIGHT$\");\n" +
"basicZoomViewer.setParam(\"serverurl\",\"https://s7d1.scene7.com/is/image/\");\n" +
"basicZoomViewer.init();\n" +
"</s" + "cript>"
);
facebookShare = new s7sdk.share.FacebookShare("socialShare", myParams);
twitterShare = new s7sdk.share.TwitterShare("socialShare", myParams);
}
myParams.addEventListener(s7sdk.Event.SDK_READY,initViewer,false);
myParams.init(); //Initialize Parameter Manager
</script>
</body>
</html>
Default styles for EmailShare:
.s7emailshare {
width:28px;
height:28px;
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);
}
.s7emailshare[state='up'] {
background-image:url(images/sdk/emailbtn_up.png);
}
.s7emailshare[state='over'] {
background-image:url(images/sdk/emailbtn_over.png);
}
.s7emailshare[state='down'] {
background-image:url(images/sdk/emailbtn_over.png);
}
.s7emailshare[state='disabled'] {
background-image:url(images/sdk/emailbtn_up.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);
}
.s7emaildialog {
position:absolute;
font-family:Helvetica;
z-index:6000;
user-select:none;
-ms-user-select:none;
-moz-user-select:-moz-none;
-webkit-user-select:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
}
.s7emaildialog input::-ms-clear {
display:none;
}
.s7emaildialog .s7backoverlay {
opacity:0.7;
background-color:#222222;
}
.s7emaildialog .s7dialog * {
box-sizing:content-box;
-moz-box-sizing:content-box;
}
.s7emaildialog .s7dialog {
border-radius:8px;
position:absolute;
background-color:#dddddd;
}
.s7emaildialog .s7dialogheader {
padding:10px;
position:relative;
}
.s7emaildialog .s7dialoglabel {
color:#666666;
font-weight:bold;
font-size:9pt;
}
.s7emaildialog .s7dialogheadericon {
position:relative;
vertical-align:middle;
display:inline-block;
background-image:url(images/sdk/dlgemail_cap.png);
width:24px;
height:17px;
}
.s7emaildialog .s7dialogheadertext {
vertical-align:middle;
padding-left:16px;
font-size:16pt;
position:relative;
font-weight:bold;
}
.s7emaildialog .s7dialogviewarea {
background-color:#ffffff;
margin:10px;
overflow:hidden;
position:relative;
height:300px;
}
.s7emaildialog .s7dialogbody {
padding:10px;
position:relative;
display:inline-block;
}
.s7emaildialog .s7dialogfooter {
border-top:1px solid #909090;
width:100%;
position:relative;
}
.s7emaildialog .s7dialogbuttoncontainer {
padding-top:10px;
padding-bottom:6px;
float:right;
position:relative;
}
.s7emaildialog .s7dialogfooter .s7button {
cursor:default;
margin-right:10px;
position:relative;
display:inline-block;
color:#ffffff;
font-size:9pt;
font-weight:bold;
text-align:center;
vertical-align:middle;
box-shadow:1px 1px 1px #999999;
line-height:34px;
}
.s7emaildialog .s7dialogline {
position:relative;
display:inline-block;
}
.s7emaildialog .s7dialogheader .s7dialogline {
padding:10px 10px 2px;
}
.s7emaildialog .s7dialogscrollpanel {
vertical-align:top;
width:44px;
height:100%;
display:inline-block;
}
.s7emaildialog .s7dialoglinefeed {
display:block;
}
.s7emaildialog .s7closebutton {
position:absolute;
top:2px;
right:2px;
padding:8px;
width:20px;
height:20px;
}
.s7emaildialog .s7closebutton[state='up'] {
background-image:url(images/sdk/close_up.png);
}
.s7emaildialog .s7closebutton[state='over'] {
background-image:url(images/sdk/close_over.png);
}
.s7emaildialog .s7closebutton[state='down'] {
background-image:url(images/sdk/close_down.png);
}
.s7emaildialog .s7closebutton[state='disabled'] {
background-image:url(images/sdk/close_disabled.png);
}
.s7emaildialog .s7dialogaddemailbutton[state='up'] {
background-image:url(images/sdk/dlgaddplus_up.png);
color:#666666;
}
.s7emaildialog .s7dialogaddemailbutton[state='over'] {
background-image:url(images/sdk/dlgaddplus_over.png);
color:#000000;
text-decoration:underline;
}
.s7emaildialog .s7dialogaddemailbutton[state='down'] {
background-image:url(images/sdk/dlgaddplus_over.png);
color:#000000;
}
.s7emaildialog .s7dialogaddemailbutton[state='disabled'] {
background-image:url(images/sdk/dlgaddplus_up.png);
color:#666666;
}
.s7emaildialog .s7dialogremoveemailbutton[state='up'] {
background-image:url(images/sdk/dlgremove_up.png);
}
.s7emaildialog .s7dialogremoveemailbutton[state='over'] {
background-image:url(images/sdk/dlgremove_over.png);
}
.s7emaildialog .s7dialogremoveemailbutton[state='down'] {
background-image:url(images/sdk/dlgremove_over.png);
}
.s7emaildialog .s7dialogremoveemailbutton[state='disabled'] {
background-image:url(images/sdk/dlgremove_up.png);
}
.s7emaildialog .s7scrollbar {
background-color:transparent;
position:absolute;
top:8px;
bottom:8px;
right:8px;
width:28px;
}
.s7emaildialog .s7scrollbar .s7scrolltrack {
background-color:rgb(178, 178, 178);
}
.s7emaildialog .s7dialoginputlabel {
margin-right:10px;
padding:10px;
position:relative;
width:50px;
display:inline-block;
text-align:right;
}
.s7emaildialog .s7dialogerrormessage {
position:relative;
display:inline-block;
background-position:left center;
background-repeat:no-repeat;
font-size:10pt;
font-weight:bold;
vertical-align:middle;
text-align:center;
padding-left:20px;
line-height:25px;
}
.s7emaildialog .s7dialogerrormessage[state='verifyerror'] {
background-image:url(images/sdk/dlgerrimg.png);
color:#ff0000;
}
.s7emaildialog .s7dialogerrormessage[state='senderror'] {
background-image:url(images/sdk/dlgerrimg.png);
color:#ff0000;
}
.s7emaildialog .s7dialogerrormessage[state='sendsuccess'] {
background-image:none;
color:#00b200;
}
.s7emaildialog .s7dialogbody .s7dialogline {
padding:10px;
}
.s7emaildialog .s7dialogviewarea[state='sendsuccess'] {
height:100px;
}
.s7emaildialog .s7dialoginputcontainer {
display:inline-block;
position:relative;
border:1px solid #cccccc;
padding:9px;
}
.s7emaildialog .s7dialogerror[error='false'] {
display:none;
}
.s7emaildialog .s7dialogerror[error='true'] {
display:inline-block;
}
.s7emaildialog .s7dialoginputcontainer[state='verifyerror'] {
border:1px solid #ff0000;
}
.s7emaildialog .s7dialoginputshort {
border:none;
width:250px;
}
.s7emaildialog .s7dialoginputwide {
border:none;
width:300px;
}
.s7emaildialog .s7dialogmessage {
white-space:-o-pre-wrap;
word-wrap:break-word;
resize:none;
height:50px;
}
.s7emaildialog .s7dialogbody .s7dialogcontent {
padding:0;
border:1px dotted #a0a0a0;
}
.s7emaildialog .s7dialogthumbnail {
position:relative;
display:inline-block;
background-position:center center;
background-repeat:no-repeat;
width:90px;
height:60px;
padding:10px;
vertical-align:top;
}
.s7emaildialog .s7dialoginfopanel {
position:relative;
width:300px;
display:inline-block;
}
.s7emaildialog .s7dialogtitle {
position:relative;
display:block;
font-weight:bold;
margin:10px;
}
.s7emaildialog .s7dialogorigin {
position:relative;
margin:10px;
display:block;
}
.s7emaildialog .s7dialogdescription {
font-size:9pt;
position:relative;
margin:10px;
display:block;
}
.s7emaildialog .s7dialogactionbutton {
width:82px;
height:34px;
}
.s7emaildialog .s7dialogactionbutton[state='up'] {
background-color:#333333;
color:#dddddd;
}
.s7emaildialog .s7dialogactionbutton[state='down'] {
background-color:#222222;
color:#cccccc;
}
.s7emaildialog .s7dialogactionbutton[state='over'] {
background-color:#222222;
color:#cccccc;
}
.s7emaildialog .s7dialogactionbutton[state='disabled'] {
background-color:#b2b2b2;
color:#dddddd;
}
.s7emaildialog .s7dialogremoveemailbutton {
position:relative;
display:inline-block;
width:25px;
height:25px;
}
.s7emaildialog .s7dialogaddemailbutton {
background-repeat:no-repeat;
position:relative;
display:inline-block;
text-align:right;
font-size:12pt;
font-weight:bold;
background-position:left center;
line-height:25px;
padding-left:30px;
height:25px;
}
.s7emaildialog .s7dialogcancelbutton {
width:64px;
height:34px;
}
.s7emaildialog .s7dialogcancelbutton[state='up'] {
background-color:#666666;
color:#e4e4e4;
}
.s7emaildialog .s7dialogcancelbutton[state='down'] {
background-color:#555555;
color:#ffffff;
}
.s7emaildialog .s7dialogcancelbutton[state='over'] {
background-color:#555555;
color:#ffffff;
}
.s7emaildialog .s7dialogcancelbutton[state='disabled'] {
background-color:#b2b2b2;
color:#e4e4e4;
}
- Parameters:
- {String} containerId
- The ID of the parent DOM element to which the component is added as a child; if an ID of the
SocialShare
component is used, this component will be added toSocialShare
panel. - {s7sdk.ParameterManager} settings
- A parameter manager instance that represents the desired configuration.
- {String} compId
- An optional parameter that specifies the ID of the component DOM element.
EmailShare
component. The handler function
receives a DOM event object of type Event
. The object contains a property s7event
,
which references the associated custom event object, for example s7sdk.event.SocialEvent
.
The events supported by the component are:
SocialEvent.NOTF_SOCIAL_ACTIVATED
- Dispatched when sharing components are activated by the user. s7sdk.event.SocialEventSocialEvent.NOTF_SOCIAL_DEACTIVATED
- Dispatched when sharing components are deactivated by the user. s7sdk.event.SocialEvent- Parameters:
- {String} type
- Event name, for example
SocialEvent.NOTF_SOCIAL_ACTIVATED
. - {Function} handler
- Function to be called when the event gets dispatched.
- {Boolean} useCapture
- Register capture phase.
- Parameters:
- {String} title
- content title
- Parameters:
- {String} contentUrl
- content URL to be shared
- Parameters:
- {String} classname
- The CSS classname to use for this style. i.e. .s7emailshare
- {String} property
- The CSS property that is being set. i.e. background-color
- {String} value
- The CSS property value being set. i.e. #FF0000
- Parameters:
- {String} descr
- description
- Parameters:
- {Object} modObj
- A simple JSON object with name:value pairs of valid modifiers for a particular component
- Parameters:
- {String} originURL
- origin URL
- Parameters:
- {String} thumbnail
- content thumbnail