Commit 9666cba3 authored by Vincent Tam's avatar Vincent Tam

File path refactored

parent d44709cf
$(document).ready(function(){
var $comments = $('.js-comments');
$('.js-form').submit(function () {
var form = this;
$(form).addClass('disabled');
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: $(this).serialize(),
contentType: 'application/x-www-form-urlencoded',
success: function (data) {
$('.page__comments-form .js-notice').removeClass('notice--danger');
$('.page__comments-form .js-notice').addClass('notice--success');
showAlert('Thanks for your comment! It will show on the site once it has been approved. .');
},
error: function (err) {
console.log(err);
$('.page__comments-form .js-notice').removeClass('notice--success');
$('.page__comments-form .js-notice').addClass('notice--danger');
showAlert('Sorry, there was an error with the submission!');
$(form).removeClass('disabled');
}
});
return false;
});
function showAlert(message) {
$('.page__comments-form .js-notice').removeClass('hidden');
$('.page__comments-form .js-notice-text').html(message);
}
$('.comment-reply-btn a').click(function (){
$('input[name="fields[replyThread]"]').val(this.title);
$('input[name="fields[replyID]"]').val(this.id);
authorTag = $(this).parents('.js-comment').children('div.comment__content-wrapper').children('h3.comment__author');
$('input[name="fields[replyName]"]').val(authorTag.text());
$('.js-form fieldset button.button').text('Submit reply');
});
$('.js-form fieldset button[type="reset"]').click(function (){
$('input[name="fields[replyThread]"]').val("");
$('input[name="fields[replyID]"]').val("");
$('input[name="fields[replyName]"]').val("");
$('.js-form fieldset button.button').text('Submit');
});
// smooth scroll to different link anchor
$('.comment-reply-target a[href^="#"]').click(function (){
targetPostID = $(this).attr('href');
targetID = "#" + $(targetPostID).parents('.js-comment').attr('id');
$('html, body').animate({ scrollTop: $(targetID).offset().top }, 500);
});
});
/* .form-group ==========================================================================
.form-group
margin-bottom: 5px
padding: 0
border-width: 0
textarea
width: 100%
/* Comments ==========================================================================
.page__comments
float: left
margin-left: 0
margin-right: 0
width: 100%
clear: both
.page__comments-title
margin-top: 2rem
margin-bottom: 10px
padding-top: 2rem
font-size: 20px
border-top: 1px solid $border-color
text-transform: uppercase
.page__comments-form
&.disabled
input, button, textarea, label
pointer-events: none
cursor: not-allowed
filter: alpha(opacity = 65)
box-shadow: none
opacity: 0.65
.comment
@extend %clearfix
margin: 1em 0
&:not(:last-child)
border-bottom: 1px solid $border-color
.comment__avatar-wrapper
float: left
width: 60px
height: 60px
.comment__avatar
width: 40px
height: 40px
border-radius: 50%
.comment__content-wrapper
float: right
width: calc(100% - 60px)
.comment__author
margin: 0
a
text-decoration: none
.comment__date
margin: 0
a
text-decoration: none
......@@ -9,3 +9,6 @@ $nunito-font-path: '{{ "fonts/NunitoSans" | absURL }}'
@import "fontawesome-import"
@import "base"
@import "{{ $themeStyle }}-style"
{{- if .Site.Params.staticman -}}
//@import "staticman"
{{- end -}}
......@@ -66,3 +66,14 @@
</div>
{{ end }}
{{ end }}
{{ define "customCSS" }}
{{ partial "css/owlCarousel.html" . }}
{{ end }}
{{ define "customScripts" }}
{{ partial "js/owlCarousel.html" . }}
{{- if .Site.Params.staticman -}}
{{ partial "js/staticman.html" . }}
{{- end -}}
{{ end }}
......@@ -11,11 +11,6 @@
<link rel="stylesheet" href="{{ $bundle.Permalink }}" integrity="{{ $bundle.Data.Integrity }}" media="screen">
{{ end }}
<!-- Staticman CSS -->
{{- if .Site.Params.staticman -}}
<link rel="stylesheet" href="{{ "css/staticman.css" | absURL }}" />
{{- end -}}
<!-- Custom css -->
{{ range .Site.Params.customCSS -}}
{{ $style := resources.Get . }}
......
{{ $staticman := resources.Get "/js/staticman.js" }}
<script src="{{ $staticman.Permalink }}"></script>
......@@ -126,67 +126,3 @@
</form>
</div>
</div>
<!-- Script for handling comment form submission and reset -->
<!-- from: https://github.com/eduardoboucas/popcorn/blob/gh-pages/js/main.js -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
(function ($) {
var $comments = $('.js-comments');
$('.js-form').submit(function () {
var form = this;
$(form).addClass('disabled');
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: $(this).serialize(),
contentType: 'application/x-www-form-urlencoded',
success: function (data) {
$('.page__comments-form .js-notice').removeClass('notice--danger');
$('.page__comments-form .js-notice').addClass('notice--success');
showAlert('Thanks for your comment! It will show on the site once it has been approved. .');
},
error: function (err) {
console.log(err);
$('.page__comments-form .js-notice').removeClass('notice--success');
$('.page__comments-form .js-notice').addClass('notice--danger');
showAlert('Sorry, there was an error with the submission!');
$(form).removeClass('disabled');
}
});
return false;
});
function showAlert(message) {
$('.page__comments-form .js-notice').removeClass('hidden');
$('.page__comments-form .js-notice-text').html(message);
}
$('.comment-reply-btn a').click(function (){
$('input[name="fields[replyThread]"]').val(this.title);
$('input[name="fields[replyID]"]').val(this.id);
authorTag = $(this).parents('.js-comment').children('div.comment__content-wrapper').children('h3.comment__author');
$('input[name="fields[replyName]"]').val(authorTag.text());
$('.js-form fieldset button.button').text('Submit reply');
});
$('.js-form fieldset button[type="reset"]').click(function (){
$('input[name="fields[replyThread]"]').val("");
$('input[name="fields[replyID]"]').val("");
$('input[name="fields[replyName]"]').val("");
$('.js-form fieldset button.button').text('Submit');
});
// smooth scroll to different link anchor
$('.comment-reply-target a[href^="#"]').click(function (){
targetPostID = $(this).attr('href');
targetID = "#" + $(targetPostID).parents('.js-comment').attr('id');
$('html, body').animate({ scrollTop: $(targetID).offset().top }, 500);
});
})(jQuery);
</script>
......@@ -40,4 +40,7 @@
{{ define "customScripts" }}
{{ partial "js/owlCarousel.html" . }}
{{- if .Site.Params.staticman -}}
{{ partial "js/staticman.html" . }}
{{- end -}}
{{ end }}
/*
.form-group
========================================================================== */
.form-group {
margin-bottom: 5px;
padding: 0;
border-width: 0;
textarea {
width: 100%;
}
}
/*
Comments
========================================================================== */
.page__comments {
float: left;
margin-left: 0;
margin-right: 0;
width: 100%;
clear: both;
}
.page__comments-title {
margin-top: 2rem;
margin-bottom: 10px;
padding-top: 2rem;
font-size: 20px;
border-top: 1px solid grey;
text-transform: uppercase;
}
.page__comments-form {
&.disabled {
input,
button,
textarea,
label {
pointer-events: none;
cursor: not-allowed;
filter: alpha(opacity=65);
box-shadow: none;
opacity: 0.65;
}
}
}
.comment {
margin: 1em 0;
&:not(:last-child) {
border-bottom: 1px solid grey;
}
}
.comment__avatar-wrapper {
float: left;
width: 60px;
height: 60px;
}
.comment__avatar {
width: 40px;
height: 40px;
border-radius: 50%;
}
.comment__content-wrapper {
float: right;
width: calc(100% - 60px);
}
.comment__author {
margin: 0;
a {
text-decoration: none;
}
}
.comment__date {
margin: 0;
a {
text-decoration: none;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment