Created
April 27, 2016 23:52
-
-
Save ryanschuhler/07266daf5c87f01ce97d258e5a4bace7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #set ($Int = 0) | |
| #set ($product = $Int.parseInt($product_key.data)) | |
| #set ($selectCssClass = "") | |
| #set ($buttonStyle = "style-b") | |
| #set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService")) | |
| #set ($accountCustomerLocalService = $serviceLocator.findService("osb-portlet", "com.liferay.osb.service.AccountCustomerLocalService")) | |
| #set ($partnerWorkerLocalService = $serviceLocator.findService("osb-portlet", "com.liferay.osb.service.PartnerWorkerLocalService")) | |
| #set ($currentURL = $request.get("attributes").get("CURRENT_URL")) | |
| #set ($esaLanguageId = "en_US") | |
| #set ($user = $userLocalService.getUser($permissionChecker.getUserId())) | |
| #set ($expandoBridge = $user.getExpandoBridge()) | |
| #set ($now = $dateUtil.newDate()) | |
| #set ($companies = "") | |
| #set ($accountCustomers = $accountCustomerLocalService.getUserAccountCustomers($permissionChecker.getUserId())) | |
| #foreach ($accountCustomer in $accountCustomers) | |
| #set ($accountEntry = $accountCustomer.getAccountEntry()) | |
| #if ($validator.isNotNull($companies)) | |
| #set ($companies = "$companies/") | |
| #end | |
| #set ($companies = "$companies$accountEntry.getName()") | |
| #end | |
| #if ($validator.isNull($companies)) | |
| #set ($partnerWorker = $partnerWorkerLocalService.getUserPartnerWorker($permissionChecker.getUserId())) | |
| #set ($partnerEntry = $partnerWorker.getPartnerEntry()) | |
| #set ($companies = $partnerEntry.getCode()) | |
| #end | |
| #set ($esa = $expandoBridge.getAttribute('osbESA')) | |
| #set ($esaVersion = 1.0) | |
| #set ($companies = $stringUtil.replace($companies, ",", "")) | |
| #set ($timeStamp = $now.getTime()) | |
| #set ($requiresESA = true) | |
| ## update this to be dynamic once we figure out a workflow with @Weston Davis | |
| #set ($esaVersionRequired = 1.0) | |
| #if ($validator.isNotNull($esa) && ($arrayUtil.getLength($esa) >= 4)) | |
| #set ($esaLanguage = $esa.get(2)) | |
| #set ($esaVersionAccepted = $getterUtil.getDouble($esa.get(3))) | |
| #if ($esaVersionAccepted >= $esaVersionRequired) | |
| #set ($requiresESA = false) | |
| #end | |
| #end | |
| #if ($download_style.data != "false" || !$download_style.data) | |
| <div class="$download_style.data"> | |
| #if (!$box_heading.data.isEmpty()) | |
| <h4> | |
| $box_heading.data | |
| </h4> | |
| #end | |
| #set ($buttonStyle = "") | |
| #end | |
| <div class="download-section esa-download"> | |
| #if (!$download_heading.data.isEmpty()) | |
| <h4> | |
| $download_heading.data | |
| </h4> | |
| #end | |
| <div class="download"> | |
| #if ($download_groups.downloads.data != "") | |
| <select id="downloadSelect${reserved-article-id.data}" onchange="AUI().one('#downloadButton${reserved-article-id.data}').attr('href', this.value)"> | |
| #foreach ($download_group in $download_groups.getSiblings()) | |
| <optgroup label="$download_group.data"> | |
| #foreach ($download in $download_group.downloads.getSiblings()) | |
| <option value="$download.link.data">$download.data</option> | |
| #end | |
| </optgroup> | |
| #end | |
| </select> | |
| #set ($selectCssClass = "float-right") | |
| #end | |
| <div class="button-group $selectCssClass"> | |
| #if ($learn_more_link.data != "") | |
| <a class="learn-more" href="$learn_more_link.data">#language('learn-more')</a> | |
| #end | |
| <a class="btn download-btn $buttonStyle" href="javascript:;" id="downloadButton${reserved-article-id.data}">#language('download')</a> | |
| </div> | |
| </div> | |
| #if ($requiresESA) | |
| <form action="$currentURL" name="esafm"> | |
| <div class="esa-checkbox"> | |
| <p>By (clicking I Accept/I agree/ checking the box)*, you confirm that you have read, understand, and agree to be bound by the terms and conditions set forth at <a href="https://www.liferay.com/legal">https://www.liferay.com/legal</a>. Notwithstanding the foregoing, if you have entered into a separate agreement with Liferay or one of its affiliates regarding the use of this software, such separate agreement controls. IF YOU ARE AN INDIVIDUAL ACTING ON BEHALF OF AN ENTITY, YOU REPRESENT THAT YOU HAVE THE AUTHORITY TO ENTER INTO THIS AGREEMENT ON BEHALF OF THAT ENTITY.</p> | |
| <input id="acceptESA" name="acceptESA" type="checkbox" /> | |
| <label for="acceptESA">I Accept</label> | |
| </div> | |
| </form> | |
| #end | |
| </div> | |
| #if ($download_style.data != "false") | |
| </div> | |
| #end | |
| <script type="text/javascript"> | |
| AUI().ready( | |
| 'aui-base', 'aui-dialog', | |
| function(A) { | |
| var downloadSelect = A.one('#downloadSelect${reserved-article-id.data}'); | |
| var submitButton = A.one('#downloadButton${reserved-article-id.data}'); | |
| var requiresESA = $requiresESA; | |
| var esaConfig = { | |
| p_auth: Liferay.authToken, | |
| companyId: 1, | |
| className: 'com.liferay.portal.model.User', | |
| tableName: 'CUSTOM_FIELDS', | |
| columnName: 'osbESA', | |
| classPK: $user.userId | |
| } | |
| function getESAData(obj) { | |
| Liferay.Service( | |
| '/expandovalue/get-data', | |
| esaConfig, | |
| processESAData | |
| ); | |
| } | |
| function processESAData(obj) { | |
| if (obj[3] && Number(obj[3]) >= Number($esaVersionRequired)) { | |
| startDownload(); | |
| } | |
| } | |
| function startDownload() { | |
| var downloadLink = '$single_download_link.data'; | |
| if (downloadSelect) { | |
| downloadLink = downloadSelect.val(); | |
| } | |
| if (downloadLink) { | |
| window.open(downloadLink); | |
| } | |
| } | |
| function submitESA() { | |
| if (document.esafm && document.esafm.acceptESA.checked) { | |
| submitViaAjax() | |
| document.esafm.acceptESA.disabled = true; | |
| } | |
| else if (!$requiresESA) { | |
| startDownload(); | |
| } | |
| else { | |
| alert('$unicodeLanguageUtil.get($locale, "you-must-agree-with-the-end-user-license-agreement-to-continue")'); | |
| } | |
| } | |
| function submitViaAjax() { | |
| if (requiresESA) { | |
| var esa = ["$timeStamp", "$companies", "$esaLanguageId", "$esaVersion"]; | |
| esaConfig.data = esa; | |
| Liferay.Service( | |
| '/expandovalue/add-value', | |
| esaConfig, | |
| getESAData | |
| ); | |
| } | |
| } | |
| if (submitButton) { | |
| submitButton.on( | |
| 'click', | |
| function() { | |
| submitESA() | |
| } | |
| ); | |
| } | |
| } | |
| ); | |
| </script> | |
| <style type="text/css"> | |
| .blue-box, .gray-box { | |
| border: 2px solid #0E4681; | |
| clear: both; | |
| } | |
| .blue-box > h4, .gray-box > h4 { | |
| background: #0E4681; | |
| color: #FFF; | |
| margin: 0; | |
| padding-left: 0.5em; | |
| } | |
| .blue-box .download-section, .gray-box .download-section { | |
| padding: 0.5em; | |
| } | |
| .gray-box { | |
| border-color: #909295; | |
| } | |
| .gray-box > h4 { | |
| background: #909295; | |
| } | |
| .download-section a:not(.download-btn) { | |
| color: #0E4681; | |
| } | |
| .download-section a:not(.download-btn):hover { | |
| color: #EF8131; | |
| } | |
| .download-section.border-bottom { | |
| border-bottom: 1px solid #CCC; | |
| } | |
| .download-section .button-group.float-right { | |
| float: right; | |
| } | |
| .download-section .button-group .download-btn { | |
| vertical-align: middle; | |
| } | |
| .download-section, .download-section .download { | |
| padding: 0.5em 0; | |
| } | |
| .download-section .download { | |
| margin-bottom: 0.5em; | |
| } | |
| .download-section .download select { | |
| background: #FFF; | |
| width: 200px; | |
| } | |
| .esa-checkbox input { | |
| vertical-align: baseline; | |
| } | |
| .learn-more { | |
| margin-right: 1em; | |
| } | |
| @media all and (max-width: 768px) { | |
| .download-section > h4 { | |
| text-align: center; | |
| } | |
| .download-section .button-group { | |
| float: none; | |
| text-align: center; | |
| } | |
| .download-section .button-group a { | |
| display: block; | |
| margin: 0.5em 0; | |
| } | |
| .download-section .download select { | |
| width: 100%; | |
| } | |
| } | |
| </style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment