-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Few minor HTML fixes * Rewrote client side script to not be in jQuery. Polyfill for older browsers.. applies to #904 * Reference FAQ and GFM Closes #1197 Auto-merge
- Loading branch information
Showing
9 changed files
with
97 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
<div id="reply-control" class="collapse"> | ||
<form action="{{{discussion.discussionPageUrl}}}" method="post"> | ||
<div class="container-fluid row user-content"> | ||
<div class="submit-panel pull-right btn-toolbar"> | ||
<button class="btn btn-sm btn-danger" type="button" data-toggle="collapse" data-target="#reply-control"><i class="fa fa-close"></i> Cancel</button> | ||
<button class="btn btn-sm btn-success" type="submit"><i class="fa fa-reply"></i> Reply</button> | ||
<div class="topic-post list-group-item"> | ||
<article> | ||
<div class="row"> | ||
<div class="topic-avatar col-sm-2"> | ||
<a href="{{{authedUser.userPageUrl}}}"> | ||
<i class="fa fa-user"></i> | ||
</a> | ||
</div> | ||
<div class="topic-body col-sm-10 container-fluid"> | ||
<div class="topic-meta-data row"> | ||
<div class="names pull-left"> | ||
<span> | ||
<a href="{{{authedUser.userPageUrl}}}" class="username">{{authedUser.name}}</a> <span class="label label-default">{{authedUser.roleName}}</span> | ||
</span> | ||
</div> | ||
<div class="post-info pull-right"> | ||
<a class="post-date"> | ||
<time datetime="" title=""></time> | ||
</a> | ||
</div> | ||
</div> | ||
<div class="topic-post-contents row"> | ||
<form action="{{{discussion.discussionPageUrl}}}" method="post"> | ||
<div class="container-fluid row user-content"> | ||
<textarea name="comment-content" data-provide="markdown" data-iconlibrary="fa" class="col-xs-12" placeholder="Type here using Markdown." required="required"></textarea> | ||
<div class="submit-panel btn-toolbar"> | ||
<a href="/about/Frequently-Asked-Questions"><i class="fa fa-book"></i></a> | ||
<a href="https://guides.github.com/features/mastering-markdown/"><i class="octicon octicon-markdown" title="GitHub Flavor Markdown compatible"></i></a> | ||
<button class="btn-sm btn btn-success pull-right" type="submit"><i class="fa fa-reply"></i> Reply</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
<textarea name="comment-content" data-provide="markdown" data-iconlibrary="fa" class="col-xs-12" placeholder="Type here using Markdown."></textarea> | ||
</div> | ||
</form> | ||
</article> | ||
</div> |
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,80 +1,47 @@ | ||
<script type="text/javascript"> | ||
(function () { | ||
'use strict'; | ||
|
||
var events = 'DOMContentLoaded load resize scroll'; | ||
var handler = null; | ||
var didCallback = false; | ||
{{> includes/scripts/polyfillElementClosest.js }} | ||
|
||
$('#reply-control').on('show.bs.collapse', function () { | ||
// Show spacer div | ||
$('#show-reply-form-when-visible').css({ | ||
height: | ||
{{#paginationRendered}}'210px'{{/paginationRendered}} | ||
{{^paginationRendered}}'268px'{{/paginationRendered}} | ||
}); | ||
}); | ||
|
||
$('#reply-control').on('hide.bs.collapse', function () { | ||
// Hide spacer div | ||
$('#show-reply-form-when-visible').css({ | ||
height: '0' | ||
}); | ||
|
||
// Clear text value from reply box | ||
$('#reply-control textarea[name="comment-content"]').val(''); | ||
}); | ||
|
||
$('.btn-comment-reply').click(function (aE) { | ||
var $comment = $(aE.target).closest('.topic-post'); | ||
var $author = $comment.find('.topic-meta-data .names .username').first(); | ||
var $replyTextarea = $('#reply-control textarea[name="comment-content"]'); | ||
function onClick(aEv) { | ||
var commentNode = document.querySelector('textarea[name="comment-content"]'); | ||
var containerNode = aEv.target.closest('.topic-post'); | ||
var authorNode = containerNode.querySelector('.topic-meta-data .names .username'); | ||
var value = null; | ||
var reUrl = null; | ||
var url = null; | ||
|
||
$('#reply-control').collapse('show'); | ||
document.location.hash = containerNode.id; | ||
|
||
document.location.hash = $comment.attr('id'); | ||
url = document.location.pathname + document.location.search + document.location.hash; | ||
url = url.replace(/\(/g, '%28').replace(/\)/g, '%29'); | ||
|
||
reUrl = document.location.pathname + | ||
document.location.search + | ||
document.location.hash; | ||
reUrl = reUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'); | ||
value = commentNode.value; | ||
|
||
value = $replyTextarea.val(); | ||
if (!/^\s*$/.test(value)) { | ||
// Add linebreaks if reply already started. | ||
value += '\n\n'; | ||
} | ||
value += '[Re](' + reUrl + '): '; | ||
value += '@' + $author.text() + ': '; | ||
value += ' \n'; | ||
$replyTextarea.val(value); | ||
$replyTextarea.focus(); | ||
}); | ||
|
||
function callback(aEl) { | ||
if (!didCallback) { | ||
didCallback = true; | ||
value += '[Re](' + url + '): '; | ||
value += '@' + authorNode.textContent + ': '; | ||
value += ' \n'; | ||
|
||
$('#reply-control').collapse('show'); | ||
$('#reply-control textarea[name="comment-content"]').focus(); | ||
} | ||
commentNode.value = value; | ||
commentNode.focus(); | ||
} | ||
|
||
{{> includes/scripts/isElementInViewport.js }} | ||
|
||
function fireIfElementVisible(aEl, aCallback) { | ||
return function () { | ||
if (isElementInViewport(aEl)) { | ||
$(window).off(events, handler); | ||
function onDOMContentLoaded(aEv) { | ||
var i = null; | ||
var thisNode = null; | ||
var replyNodes = document.querySelectorAll('.btn-comment-reply'); | ||
|
||
aCallback(aEl); | ||
} | ||
for (i = 0; thisNode = replyNodes[i++];) { | ||
thisNode.addEventListener('click', onClick); | ||
} | ||
} | ||
|
||
handler = fireIfElementVisible($('#show-reply-form-when-visible'), callback); | ||
$(window).on(events, handler); | ||
document.addEventListener('DOMContentLoaded', onDOMContentLoaded); | ||
|
||
})(); | ||
</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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// IE8+, Opera Presto, and older browser Element.Polyfill | ||
|
||
if (window.Element && !Element.prototype.closest) { | ||
Element.prototype.closest = | ||
function(aSelector) { | ||
var matches = (this.document || this.ownerDocument).querySelectorAll(aSelector); | ||
var i; | ||
var el = this; | ||
|
||
do { | ||
i = matches.length; | ||
while (--i >= 0 && matches.item(i) !== el) { | ||
}; | ||
} while ((i < 0) && (el = el.parentElement)); | ||
|
||
return el; | ||
}; | ||
} |
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 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