-
Notifications
You must be signed in to change notification settings - Fork 80
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 #455 from hasgeek/widget
Add support to embed hasjob iframe on any third party website
- Loading branch information
Showing
14 changed files
with
255 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.hasjob-iframe | ||
background: none | ||
height: auto | ||
|
||
#main-content | ||
width: 100% | ||
|
||
#root | ||
margin-bottom: 0 | ||
|
||
#root_footer | ||
height: 0 |
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 |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
@import "stickie" | ||
@import "40x" | ||
@import "animate" | ||
@import "embed" |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 +1 @@ | ||
{"assets":{"vendor":"js/vendor.3246dcaf06972fc8f57c.js","app-css":"css/stylesheet-app-css.3246dcaf06972fc8f57c.css","app":"js/app.3246dcaf06972fc8f57c.js","manifest":"js/manifest.3246dcaf06972fc8f57c.js"}} | ||
{"assets":{"vendor":"js/vendor.b055f8ff6a09d10ba3b0.js","app-css":"css/stylesheet-app-css.b055f8ff6a09d10ba3b0.css","app":"js/app.b055f8ff6a09d10ba3b0.js","manifest":"js/manifest.b055f8ff6a09d10ba3b0.js"}} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
(function() { | ||
var containerDivs = document.getElementsByClassName('hasjob-embed'); | ||
var hostnames = []; | ||
var urlParserElem = document.createElement('a'); | ||
for (var index = 0; index < containerDivs.length; index++) { | ||
var iframeSrc, iframeId, hasjobIframe; | ||
urlParserElem.href = containerDivs[index].getAttribute('data-href'); | ||
hostnames.push(urlParserElem.origin); | ||
iframeId = containerDivs[index].getAttribute('data-iframe-id'); | ||
if(!iframeId) { | ||
iframeId = 'hasjob-iframe-' + Math.random().toString(36).slice(3); | ||
} | ||
if(urlParserElem.search) { | ||
iframeSrc = urlParserElem + '&embed=1&limit='; | ||
} else { | ||
iframeSrc = urlParserElem.origin + '/?embed=1&limit='; | ||
} | ||
iframeSrc = iframeSrc + | ||
containerDivs[index].getAttribute('data-jobpost-limit') + | ||
'&iframeid=' + iframeId; | ||
hasjobIframe = document.createElement('iframe'); | ||
setAttributes(hasjobIframe, { | ||
'id': iframeId, | ||
'src': iframeSrc, | ||
'width': '100%', | ||
'height': '500px', | ||
'frameborder': '0', | ||
'scrolling': 'no' | ||
}); | ||
containerDivs[index].appendChild(hasjobIframe); | ||
} | ||
function setAttributes(element, attributes) { | ||
for(var name in attributes) { | ||
element.setAttribute(name, attributes[name]); | ||
} | ||
} | ||
function handleMessage(event) { | ||
if(hostnames.indexOf(event.origin) !== -1) { | ||
var message = JSON.parse(event.data); | ||
if(message.context == "iframe.resize" && message.id) { | ||
document.getElementById(message.id).setAttribute('height', message.height); | ||
} | ||
} | ||
} | ||
window.addEventListener('message', handleMessage, false); | ||
})(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{%- extends "layout.html.jinja2" -%} | ||
|
||
{%- block layoutheaders %} | ||
<link rel="icon" sizes="192x192" href="/static/img/hasjob-logo.svg"> | ||
<link rel="stylesheet" type="text/css" href='{{ asset_path('app-css') }}' /> | ||
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Fira+Sans:400,400i,700,700i|McLaren&subset=latin-ext"> | ||
{# | ||
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=McLaren" /> | ||
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Fira+Sans:400,700,400italic,700italic&subset=latin,latin-ext"> | ||
<link rel="stylesheet" type="text/css" href="//code.cdn.mozilla.net/fonts/fira.css"> | ||
-#} | ||
<script> | ||
if (typeof window.Hasjob === 'undefined') { | ||
window.Hasjob = {}; | ||
} | ||
// Use Hasjob.Config for server-generated responses | ||
if (typeof window.Hasjob.Config === 'undefined') { | ||
window.Hasjob.Config = { | ||
baseURL: "/" | ||
} | ||
} | ||
</script> | ||
{%- endblock %} | ||
|
||
{% block bodytag %} | ||
<body class="hasjob-iframe"> | ||
{% endblock %} | ||
|
||
{% block headerbox %} | ||
{% endblock %} | ||
|
||
{% block basecontent -%} | ||
<div id='main-content'> | ||
{% block pagecontent %} | ||
{% block content %}{% endblock %} | ||
{% endblock %} | ||
</div> | ||
{%- endblock %} | ||
|
||
{% block basefooter -%} | ||
{% endblock %} | ||
|
||
{% block footer %} | ||
{% endblock %} | ||
|
||
{% block layoutscripts %} | ||
<script type="text/javascript"> | ||
window.Hasjob.sendIframeSize = function() { | ||
window.parent.postMessage(JSON.stringify({ | ||
context: "iframe.resize", | ||
height: document.body.scrollHeight, | ||
width: document.body.scrollWidth, | ||
id: {{ request.args.get('iframeid') | tojson }} | ||
}), '*'); | ||
}; | ||
window.addEventListener('resize', window.Hasjob.sendIframeSize, false); | ||
window.addEventListener('load', window.Hasjob.sendIframeSize, false); | ||
</script> | ||
{% endblock %} |
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
Oops, something went wrong.