-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #968 from uclibs/lisa3711-new2-contactform
New Contact Form- Iframe embed
- Loading branch information
Showing
13 changed files
with
102 additions
and
321 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,97 @@ | ||
<script src='https://www.google.com/recaptcha/api.js'></script> | ||
<div class="alert alert-info"> | ||
<%= render 'directions' %> | ||
</div> | ||
|
||
<h1> | ||
<%= t('hyrax.contact_form.header') %> | ||
</h1> | ||
|
||
<% if user_signed_in? %> | ||
<% nm = current_user.name %> | ||
<% em = current_user.email %> | ||
<% else %> | ||
<% nm = '' %> | ||
<% em = '' %> | ||
<% end %> | ||
|
||
<%= form_for @contact_form, url: hyrax.contact_form_index_path, | ||
html: { class: 'form-horizontal' } do |f| %> | ||
<%= f.text_field :contact_method, class: 'hide' %> | ||
|
||
<div class="form-group"> | ||
<%= f.label :name, t('hyrax.contact_form.name_label'), class: "col-sm-2 control-label" %> | ||
<div class="col-sm-10"><%= f.text_field :name, value: nm, class: 'form-control', required: true %></div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :email, t('hyrax.contact_form.email_label'), class: "col-sm-2 control-label" %> | ||
<div class="col-sm-10"><%= f.text_field :email, value: em, class: 'form-control', required: true %></div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :subject, t('hyrax.contact_form.subject_label'), class: "col-sm-2 control-label" %> | ||
<div class="col-sm-10"><%= f.text_field :subject, class: 'form-control', required: true %></div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :message, t('hyrax.contact_form.message_label'), class: "col-sm-2 control-label" %> | ||
<div class="col-sm-10"><%= f.text_area :message, rows: 4, class: 'form-control', required: true %></div> | ||
</div> | ||
|
||
<% if current_user.blank? %> | ||
<div class="g-recaptcha" data-sitekey= "<%=CAPTCHA_SERVER['site_key']%>"></div> | ||
<% end %> | ||
|
||
<%= f.submit value: t('hyrax.contact_form.button_label'), class: "btn btn-primary" %> | ||
<% end %> | ||
<iframe | ||
id="JotFormIFrame-220205071955146" | ||
title="Scholar at UC Contact Form" | ||
onload="window.parent.scrollTo(0,0)" | ||
allowtransparency="true" | ||
allowfullscreen="true" | ||
allow="geolocation; microphone; camera" | ||
src="https://form.jotform.com/220205071955146" | ||
frameborder="0" | ||
style=" | ||
min-width: 100%; | ||
height:539px; | ||
border:none;" | ||
scrolling="no" | ||
> | ||
</iframe> | ||
<script type="text/javascript"> | ||
var ifr = document.getElementById("JotFormIFrame-220205071955146"); | ||
if (ifr) { | ||
var src = ifr.src; | ||
var iframeParams = []; | ||
if (window.location.href && window.location.href.indexOf("?") > -1) { | ||
iframeParams = iframeParams.concat(window.location.href.substr(window.location.href.indexOf("?") + 1).split('&')); | ||
} | ||
if (src && src.indexOf("?") > -1) { | ||
iframeParams = iframeParams.concat(src.substr(src.indexOf("?") + 1).split("&")); | ||
src = src.substr(0, src.indexOf("?")) | ||
} | ||
iframeParams.push("isIframeEmbed=1"); | ||
ifr.src = src + "?" + iframeParams.join('&'); | ||
} | ||
window.handleIFrameMessage = function(e) { | ||
if (typeof e.data === 'object') { return; } | ||
var args = e.data.split(":"); | ||
if (args.length > 2) { iframe = document.getElementById("JotFormIFrame-" + args[(args.length - 1)]); } else { iframe = document.getElementById("JotFormIFrame"); } | ||
if (!iframe) { return; } | ||
switch (args[0]) { | ||
case "scrollIntoView": | ||
iframe.scrollIntoView(); | ||
break; | ||
case "setHeight": | ||
iframe.style.height = args[1] + "px"; | ||
break; | ||
case "collapseErrorPage": | ||
if (iframe.clientHeight > window.innerHeight) { | ||
iframe.style.height = window.innerHeight + "px"; | ||
} | ||
break; | ||
case "reloadPage": | ||
window.location.reload(); | ||
break; | ||
case "loadScript": | ||
if( !window.isPermitted(e.origin, ['jotform.com', 'jotform.pro']) ) { break; } | ||
var src = args[1]; | ||
if (args.length > 3) { | ||
src = args[1] + ':' + args[2]; | ||
} | ||
var script = document.createElement('script'); | ||
script.src = src; | ||
script.type = 'text/javascript'; | ||
document.body.appendChild(script); | ||
break; | ||
case "exitFullscreen": | ||
if (window.document.exitFullscreen) window.document.exitFullscreen(); | ||
else if (window.document.mozCancelFullScreen) window.document.mozCancelFullScreen(); | ||
else if (window.document.mozCancelFullscreen) window.document.mozCancelFullScreen(); | ||
else if (window.document.webkitExitFullscreen) window.document.webkitExitFullscreen(); | ||
else if (window.document.msExitFullscreen) window.document.msExitFullscreen(); | ||
break; | ||
} | ||
var isJotForm = (e.origin.indexOf("jotform") > -1) ? true : false; | ||
if(isJotForm && "contentWindow" in iframe && "postMessage" in iframe.contentWindow) { | ||
var urls = {"docurl":encodeURIComponent(document.URL),"referrer":encodeURIComponent(document.referrer)}; | ||
iframe.contentWindow.postMessage(JSON.stringify({"type":"urls","value":urls}), "*"); | ||
} | ||
}; | ||
window.isPermitted = function(originUrl, whitelisted_domains) { | ||
var url = document.createElement('a'); | ||
url.href = originUrl; | ||
var hostname = url.hostname; | ||
var result = false; | ||
if( typeof hostname !== 'undefined' ) { | ||
whitelisted_domains.forEach(function(element) { | ||
if( hostname.slice((-1 * element.length - 1)) === '.'.concat(element) || hostname === element ) { | ||
result = true; | ||
} | ||
}); | ||
return result; | ||
} | ||
}; | ||
if (window.addEventListener) { | ||
window.addEventListener("message", handleIFrameMessage, false); | ||
} else if (window.attachEvent) { | ||
window.attachEvent("onmessage", handleIFrameMessage); | ||
} | ||
</script> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,10 @@ | |
# config.admin_set_predicate = ::RDF::DC.isPartOf | ||
|
||
# Email recipient of messages sent via the contact form | ||
config.contact_email = "[email protected]" | ||
# config.contact_email = "[email protected]" | ||
|
||
# Text prefacing the subject entered in the contact form | ||
config.subject_prefix = "Scholar@UC Contact form:" | ||
# config.subject_prefix = "Scholar@UC Contact form:" | ||
|
||
# How many notifications should be displayed on the dashboard | ||
# config.max_notifications_for_dashboard = 5 | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.