Skip to content

Commit

Permalink
Remote control questions highlighting (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
singhsanket143 authored and peter-hank committed Aug 22, 2019
1 parent f3698e5 commit 7a6fa82
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ reactive-var
juliancwirko:s-alert
panter:qrcode
pascoual:pdfkit
yuukan:streamy
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,4 @@ vazco:[email protected]
[email protected]
[email protected]
xolvio:[email protected]
yuukan:[email protected]
5 changes: 5 additions & 0 deletions client/views/helpers/chunks/question_div/question_div.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
{{/if}}
</span>
</div>
{{#if adminButtons}}
<div class="question-highlight">
<label class="remote-highlight"><input type="checkbox" name="highlight" value="0"> Highlight the question</label>
</div>
{{/if}}
<div class="asked-by">
{{#if poster}}
<span class="poser">
Expand Down
17 changes: 17 additions & 0 deletions client/views/helpers/chunks/question_div/question_div.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Votes, Answers, Instances, Questions } from '/lib/common.js';

Streamy.on('emphasize', function(data, s) {
$(`#${data.id}`).find('p.questiontext').css('background-color', 'yellow');
});

Streamy.on('de-emphasize', function(data, s) {
$(`#${data.id}`).find('p.questiontext').css('background-color', '');
});

Template.question_div.onCreated(function () {
this.replyCount = new ReactiveVar(0);
});
Expand Down Expand Up @@ -101,4 +109,13 @@ Template.question_div.events({
const parentNode = document.getElementById('nav');
popoverTemplate = Blaze.renderWithData(Template.modify, template.data._id, parentNode);
},
'change .remote-highlight': function(event, template) {
const currInstance = Instances.findOne({ _id: template.data.instanceid });
let id = event.currentTarget.parentElement.parentElement.id;
if (event.target.checked === true) {
Meteor.call('emphasize', id, template.data.instanceid);
} else {
Meteor.call('deEmphasize', id, template.data.instanceid);
}
}
});
21 changes: 21 additions & 0 deletions client/views/helpers/chunks/question_div/question_div.scss
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,24 @@ $popular-question-color: #f1c40f;
font-weight: 600;
color: #777!important;
}

.remote-highlight:hover, input[type='checkbox'] {
cursor: pointer;
}

.remote-highlight {
display: block;
padding-left: 15px;
text-indent: -15px;
}

.remote-highlight > input {
width: 13px;
height: 13px;
padding: 0;
margin:0;
vertical-align: bottom;
position: relative;
top: -1px;
overflow: hidden;
}
14 changes: 14 additions & 0 deletions server/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,5 +759,19 @@ Meteor.methods({
}
console.log("OK");
return true;
},
emphasize(divId, instanceId) {
let currUser = Meteor.users.findOne({ _id: this.userId });
let currInstance = Instances.findOne({ _id: instanceId });
if (currInstance.admin === currUser.emails[0].address) {
Streamy.broadcast('emphasize', { id: divId });
}
},
deEmphasize(divId, instanceId) {
let currUser = Meteor.users.findOne({ _id: this.userId });
let currInstance = Instances.findOne({ _id: instanceId });
if (currInstance.admin === currUser.emails[0].address) {
Streamy.broadcast('de-emphasize', { id: divId });
}
}
});

0 comments on commit 7a6fa82

Please sign in to comment.