1
0
Fork 0
docsearch/docs/source/assets/javascripts/main.js
Sylvain Pace 4c9b860cd8
Update the community website regarding our open source project policy (#358)
* first draft regarding our open source project policy

fixing middleman build

adding style enhancing

fix

fix link

learning haml

enhance faq

enhance faq

disabling code

precise our philosophy

docs: fix typos

Update 2-not-an-open-source-project.html.md.erb

Update index.html.haml

Update index.html.haml

Update join-form.haml

Update 2-not-an-open-source-project.html.md.erb

Introducing the first feedback

integrate final feedback

* first draft regarding our open source project policy

fixing middleman build

adding style enhancing

fix

fix link

learning haml

enhance faq

enhance faq

disabling code

precise our philosophy

docs: fix typos

Update 2-not-an-open-source-project.html.md.erb

Update index.html.haml

Update index.html.haml

Update join-form.haml

Update 2-not-an-open-source-project.html.md.erb

Introducing the first feedback

integrate final feedback

* new draft regarding our policy

* fixing style

* fix

* enhance form

* enhance form

* fixing title

* new deploy

* adding missing package
2018-08-01 09:45:58 +02:00

77 lines
2 KiB
JavaScript

//= require ./vendors/clipboard.min.js
//= require ./components/copy-link.js
function setScreen() {
const screens = [
'screen_react',
'screen_laravel',
'screen_akka',
'screen_bootstrap',
'screen_vue',
'screen_middleman',
];
const rand = Math.floor(Math.random() * (screens.length - 0) + 0);
const imgPath = 'assets/images/screens/';
const screenImage = document.createElement('img');
const imageHolder = document.querySelector('#demo-screens');
const imagePlaceholder = document.querySelector('#placeholder');
if (imagePlaceholder) {
screenImage.classList.add('demo-screen', 'w100p', 'elevation1');
screenImage.src = imgPath + screens[rand] + '.png';
imagePlaceholder.remove();
imageHolder.appendChild(screenImage);
}
}
window.addEventListener('load', function() {
setScreen();
document.body.classList.add('ready');
(function($) {
$('.join-form').on('submit', function(e) {
e.preventDefault();
var $email = $(this).find('input[name="email"]');
var $url = $(this).find('input[name="url"]');
var $owner = $(this).find('input[name="owner"]');
var error = false;
$(this).find('.has-errors').removeClass('has-errors');
if (!$email.val()) {
$email.closest('.input-group').addClass('has-errors');
error = true;
}
if (!$url.val()) {
$url.closest('.input-group').addClass('has-errors');
error = true;
}
if (!$owner.is(':checked')) {
$owner.addClass('has-errors');
error = true;
}
if (error) {
return false;
}
$.ajax({
url: 'https://www.algolia.com/docsearch/join',
type: 'POST',
data: {
email: $email.val(),
url: $url.val()
}
}).done(function() {
$('.join-form-fill').hide();
$('.join-form-validated').removeClass('hidden');
})
.fail(function() {
alert('An error occurred, please try again later.');
});
return false;
});
})(jQuery);
});