Skip to content

Commit

Permalink
add feature to sidebar, questions code overhaul (#1335)
Browse files Browse the repository at this point in the history
* add feature to sidebar

* reorg of questions assets

* work on questions by path not session

* feature sidebar final fixes

* test fix

* questions fixes
  • Loading branch information
jywarren authored Mar 16, 2017
1 parent 8e86d9e commit f40642c
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 326 deletions.
47 changes: 47 additions & 0 deletions app/assets/javascripts/question.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
jQuery(document).ready(function(){

var check_matched = false;
var stripped_url = document.location.toString().split("#");
if (stripped_url.length > 1){
var anchor_value = stripped_url[1];
if(anchor_value.match('answer-0-comment')){
check_matched = true;
}
}

if (check_matched){
$('.answer-0-comments').show();
}
else{
$('.answer-0-comments').slice(-3).show();
if (<%= @node.comments.length %> > 3){
$('#answer-0-comment').prepend('<p id="answer-0-expand" style="color: #006dcc;">View ' + comment_select(0).length + ' previous comments</p>');
$("#answer-0-expand").on('click',function(){
expand_comments(0);
});
}
}

$('#answer-0-comment-form').bind('ajax:send', function(e){
$('#answer-0-comment-form #loading-spinner').removeClass('hidden');
$('#answer-0-comment-form #reply-comment').addClass('hidden');
$('#answer-0-comment-form #submit-comment-button').addClass('disabled');
$('#answer-0-comment-form #submit-comment').text('Submitting');
})

$('#answer-0-comment-form').bind('ajax:success', function(e, data, status, response){
$('#answer-0-comment-form #loading-spinner').addClass('hidden');
$('#answer-0-comment-form #reply-comment').removeClass('hidden');
$('#answer-0-comment-form #submit-comment').text('Submit');
$('#answer-0-comment-form #submit-comment-button').removeClass('disabled');
})

$('#answer-0-comment-form').bind('ajax:error', function(e, response){
$('#answer-0-comment-form #loading-spinner').addClass('hidden');
$('#answer-0-comment-form #reply-comment').removeClass('hidden');
$('#answer-0-comment-form #submit-comment').text('Submit');
$('#answer-0-comment-form #submit-comment-button').removeClass('disabled');
$('#answer-0-comment-section .help-block').remove()
$('#answer-0-comment-section .inline').last().append('<span class="help-block" style="color: red;">Error: there was a problem.</span>')
})
})
7 changes: 3 additions & 4 deletions app/assets/javascripts/questions_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// To be removed or modified accordingly by Advanced Search Project

jQuery(document).ready(function(){

$('.typeahead.dropdown-menu li').addClass('col-xs-12');
$('#questions_searchform_input').submit(function(e){
$('.typeahead.dropdown-menu li').addClass('col-xs-12');
$('#questions_searchform_input').submit(function(e){
e.preventDefault()
window.location = '/questions_search/' + $('#questions_searchform_input').val()
})
Expand All @@ -24,4 +23,4 @@ jQuery(document).ready(function(){
window.location = url;
}
})
})
})
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
*= require search
*= require comments
*= require wiki
*= require question
*/
117 changes: 117 additions & 0 deletions app/assets/stylesheets/question.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
.question-show .question {
color: #aaa;
font-style: italic;
}
.question-show .question + a {
text-decoration: none;
}

.question-show .inline {
display: inline-block;
}

.question-show .inline img.img-circle {
vertical-align: baseline;
width: 35px;
margin-right: 6px;
}

.question-show .inline div.img-circle {
vertical-align: middle;
height: 35px;
width: 35px;
margin-right: 6px;
background: #ccc;
}

#questions_searchform .dropdown-menu {
width: 95%;
}

.answer p img {
max-width:100%;
}

.answer-accept {
font-weight: bold;
}

.answer-accept.btn-success {
color: #fff;
}

.accepted {
background: #76e276;
}

.user-answer {
margin-top: 10px;
margin-bottom: 5px;
padding: 10px;
display:none;
background-color: #fff;
border-radius: 5px;
}

table th a {
color: #333;
text-decoration: underline;
}

table th a:hover {
color: #aaa;
}

.expandingArea {
position: relative;
margin-top: 2px;
border: 1px solid #ccc;
border-radius: 4px;
background: #fff;
}
.expandingArea > textarea,
.expandingArea > pre {
padding: 6px 12px;
background: transparent;
border: 0;
/* Make the text soft-wrap */
white-space: pre-wrap;
word-wrap: break-word;
}
.expandingArea > textarea {
/* The border-box box model is used to allow
* padding whilst still keeping the overall width
* at exactly that of the containing element.
*/
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
}
.expandingArea.active > textarea {
/* Hide any scrollbars */
overflow: hidden;
position: absolute;
top: 0;
left: 0;
height: 100%;
/* Remove WebKit user-resize widget */
resize: none;
}
.expandingArea > pre {
display: none;
}
.expandingArea.active > pre {
display: block;
/* Hide the text; just using it for sizing */
visibility: hidden;
}

.question-show textarea,
.question-show pre {
margin: 0;
padding: 0;
outline: 0;
border: 0;
}
127 changes: 0 additions & 127 deletions app/assets/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,6 @@ body { padding-top: 70px; }
margin-bottom: 10px;
}


#carousel h1, #carousel h2, #carousel h3, #carousel h4, #carousel h5 {
color:white;
}

#carousel i { /* hide the permalink anchors */
display:none;
}

.controls fieldset {
padding: 5px;
border-left: 2px solid #cccccc;
Expand Down Expand Up @@ -354,43 +345,13 @@ div.note.moderated h4 {
font-size: smaller;
}

.answer p img {
max-width:100%;
}

.note p.moderated .btn {
color: #940;
border-color: #eb8;
background: none;
font-size: smaller;
}

.question{
color: #aaa;
font-style: italic;
}
.question + a{
text-decoration: none;
}

.inline{
display: inline-block;
}

.inline img.img-circle{
vertical-align: baseline;
width: 35px;
margin-right: 6px;
}

.inline div.img-circle{
vertical-align: middle;
height: 35px;
width: 35px;
margin-right: 6px;
background: #ccc;
}

.btn-primary {
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
background-color: #006dcc;
Expand All @@ -407,94 +368,6 @@ div.note.moderated h4 {
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
}

#questions_searchform .dropdown-menu {
width: 95%;
}

textarea,
pre {
margin: 0;
padding: 0;
outline: 0;
border: 0;
}

.expandingArea {
position: relative;
margin-top: 2px;
border: 1px solid #ccc;
border-radius: 4px;
background: #fff;
}
.expandingArea > textarea,
.expandingArea > pre {
padding: 6px 12px;
background: transparent;
border: 0;
/* Make the text soft-wrap */
white-space: pre-wrap;
word-wrap: break-word;
}
.expandingArea > textarea {
/* The border-box box model is used to allow
* padding whilst still keeping the overall width
* at exactly that of the containing element.
*/
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
}
.expandingArea.active > textarea {
/* Hide any scrollbars */
overflow: hidden;
position: absolute;
top: 0;
left: 0;
height: 100%;
/* Remove WebKit user-resize widget */
resize: none;
}
.expandingArea > pre {
display: none;
}
.expandingArea.active > pre {
display: block;
/* Hide the text; just using it for sizing */
visibility: hidden;
}

.answer-accept {
font-weight: bold;
}

.answer-accept.btn-success {
color: #fff;
}

.accepted {
background: #76e276;
}

.user-answer {
margin-top: 10px;
margin-bottom: 5px;
padding: 10px;
display:none;
background-color: #fff;
border-radius: 5px;
}

table th a {
color: #333;
text-decoration: underline;
}

table th a:hover {
color: #aaa;
}

@media (max-width:768px) {
table {
font-size: 90%;
Expand Down
12 changes: 0 additions & 12 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,4 @@ def redirect_old_urls
end
end

def sort_question_by_tags
if session[:tags] && !session[:tags].empty?
@session_tags = session[:tags]
qids = @questions.collect(&:nid)
@questions = Node.where(status: 1, type: 'note')
.joins(:tag)
.where('term_data.name IN (?)', @session_tags.values)
.where('node.nid IN (?)', qids)
.group('node.nid')
end
end

end
Loading

0 comments on commit f40642c

Please sign in to comment.