Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature remote control highlight #134

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:universe-html-purifier@1.2.3
webapp@1.3.11
webapp-hashing@1.0.9
xolvio:cleaner@0.3.1
yuukan:streamy@1.4.1
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 });
}
}
});