2017-08-03 00:24:01 +03:00
|
|
|
window.$ = require('jquery')
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
2017-08-24 19:23:03 +03:00
|
|
|
function pwcheck (e) {
|
|
|
|
var pw = $('#password').val()
|
|
|
|
var pwa = $('#password_repeat').val()
|
|
|
|
if (pwa !== pw) {
|
|
|
|
$('#password_repeat').addClass('invalid')
|
|
|
|
$('#repeatcheck').show()
|
|
|
|
$('#repeatcheck').html('<span class="error">The passwords do not match.</span>')
|
|
|
|
} else {
|
|
|
|
$('#password_repeat').removeClass('invalid')
|
|
|
|
$('#repeatcheck').hide()
|
|
|
|
$('#repeatcheck').html('')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-25 14:37:34 +03:00
|
|
|
window.Dialog = $('#dialog')
|
|
|
|
window.Dialog.open = function (title, content, pad) {
|
|
|
|
$('#dialog #title').text(title)
|
|
|
|
if (pad) {
|
|
|
|
content = '<div class="pad">' + content + '</div>'
|
|
|
|
}
|
|
|
|
$('#dialog #content').html(content)
|
|
|
|
$('#dialog').fadeIn()
|
|
|
|
}
|
|
|
|
|
|
|
|
window.Dialog.close = function () {
|
|
|
|
$('#dialog').fadeOut('fast', function () {
|
|
|
|
$('#dialog #content').html('')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
window.Dialog.openPartial = function (title, partial) {
|
|
|
|
$.get({
|
|
|
|
url: '/partials/' + partial,
|
|
|
|
success: function (html) {
|
|
|
|
window.Dialog.open(title, html, false)
|
|
|
|
}
|
|
|
|
}).fail(function (e) {
|
|
|
|
console.error(e)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#dialog #close').click(function (e) {
|
|
|
|
window.Dialog.close()
|
|
|
|
})
|
|
|
|
|
2017-08-24 00:42:55 +03:00
|
|
|
if (window.location.hash) {
|
2017-08-24 19:23:03 +03:00
|
|
|
var locha = window.location.hash
|
2017-08-24 13:52:12 +03:00
|
|
|
if ($(locha).length) {
|
|
|
|
$(window).scrollTop($(locha).offset().top - $('.navigator').innerHeight() * 2)
|
2017-08-24 00:42:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-24 19:23:03 +03:00
|
|
|
$(window).on('scroll', function () {
|
|
|
|
if ($(window).scrollTop() >= $('.banner').innerHeight()) {
|
2017-08-03 00:24:01 +03:00
|
|
|
$('.anchor').css('height', $('.navigator').innerHeight() + 'px')
|
|
|
|
$('#navlogo').removeClass('hidden')
|
|
|
|
$('.navigator').addClass('fix')
|
|
|
|
} else {
|
|
|
|
$('#navlogo').addClass('hidden')
|
|
|
|
$('.navigator').removeClass('fix')
|
|
|
|
$('.anchor').css('height', '0px')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-08-24 19:23:03 +03:00
|
|
|
if ($(window).scrollTop() >= $('.banner').innerHeight()) {
|
2017-08-03 00:24:01 +03:00
|
|
|
$('#navlogo').removeClass('hidden')
|
|
|
|
$('.navigator').addClass('fix')
|
|
|
|
$('.anchor').css('height', $('.navigator').innerHeight() + 'px')
|
|
|
|
}
|
|
|
|
|
|
|
|
$('a[href*=\\#]').on('click', function (e) {
|
|
|
|
if (!$(this.hash).length) return
|
|
|
|
e.preventDefault()
|
|
|
|
|
2017-08-24 13:52:12 +03:00
|
|
|
var dest = 0
|
2017-08-03 00:24:01 +03:00
|
|
|
if ($(this.hash).offset().top > $(document).height() - $(window).height()) {
|
2017-08-24 19:23:03 +03:00
|
|
|
dest = $(document).height() - $(window).height()
|
2017-08-03 00:24:01 +03:00
|
|
|
} else {
|
2017-08-24 19:23:03 +03:00
|
|
|
dest = $(this.hash).offset().top
|
2017-08-03 00:24:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$('html,body').animate({
|
2017-08-24 19:23:03 +03:00
|
|
|
scrollTop: dest - $('.navigator').innerHeight()
|
2017-08-03 00:24:01 +03:00
|
|
|
}, 1000, 'swing')
|
|
|
|
})
|
2017-08-03 15:57:17 +03:00
|
|
|
|
2017-08-24 00:42:55 +03:00
|
|
|
$('#mobile').click(function (e) {
|
|
|
|
e.preventDefault()
|
|
|
|
$('.flexview').toggleClass('extended')
|
|
|
|
})
|
|
|
|
|
2017-08-24 19:23:03 +03:00
|
|
|
$('body').click(function (e) {
|
2017-08-24 00:42:55 +03:00
|
|
|
if (!$(e.target).is('#mobile') && !$(e.target).is('#mobile i') && $('.flexview').hasClass('extended')) {
|
|
|
|
$('.flexview').removeClass('extended')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
if ($('#repeatcheck').length) {
|
|
|
|
$('#password_repeat').on('keyup', pwcheck)
|
|
|
|
$('#password').on('keyup', function (e) {
|
|
|
|
if ($('#password_repeat').val()) {
|
|
|
|
pwcheck(e)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-08-24 13:52:12 +03:00
|
|
|
if ($('.newsfeed').length) {
|
|
|
|
$.ajax({
|
|
|
|
type: 'get',
|
|
|
|
url: '/api/news',
|
|
|
|
dataType: 'json',
|
|
|
|
success: function (data) {
|
|
|
|
if (!data.length) {
|
|
|
|
return $('.newsfeed').html('There is nothing to show at this moment.')
|
|
|
|
}
|
|
|
|
var html = ''
|
|
|
|
for (var i in data) {
|
|
|
|
var article = data[i]
|
|
|
|
html += '<div class="prvarticle">'
|
|
|
|
html += '<a class="title" href="/news/' + article.id + '-' + article.slug + '">' + article.title + '</a>'
|
|
|
|
html += '<span class="timestamp">Published at ' + new Date(article.created_at) + '</span>'
|
|
|
|
html += '<div class="prvcontent">' + article.content + '</div>'
|
|
|
|
html += '<a href="/news/' + article.id + '-' + article.slug + '">Read More</a>'
|
|
|
|
html += '</div>'
|
|
|
|
}
|
|
|
|
$('.newsfeed').html(html)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-08-03 15:57:17 +03:00
|
|
|
window.checkLoginState = function () {
|
2017-08-24 19:23:03 +03:00
|
|
|
var FB = window.FB
|
|
|
|
FB.getLoginStatus(function (response) {
|
2017-08-03 15:57:17 +03:00
|
|
|
$.ajax({
|
|
|
|
type: 'post',
|
|
|
|
url: '/api/external/facebook/callback',
|
|
|
|
dataType: 'json',
|
|
|
|
data: response,
|
2017-08-24 13:52:12 +03:00
|
|
|
success: function (data) {
|
2017-08-24 21:36:40 +03:00
|
|
|
console.log(data)
|
2017-08-03 15:57:17 +03:00
|
|
|
if (data.error) {
|
|
|
|
$('.message').addClass('error')
|
|
|
|
$('.message span').text(data.error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.redirect) {
|
2017-08-24 19:23:03 +03:00
|
|
|
window.location.href = data.redirect
|
|
|
|
return
|
2017-08-03 15:57:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
window.location.reload()
|
|
|
|
}
|
2017-08-24 19:23:03 +03:00
|
|
|
}).fail(function () {
|
2017-08-03 15:57:17 +03:00
|
|
|
$('.message').addClass('error')
|
|
|
|
$('.message span').text('An error occured.')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2017-08-03 00:24:01 +03:00
|
|
|
})
|