This commit is contained in:
Kenneth Jao 2016-10-20 21:54:55 -04:00
commit fb073243d9
2 changed files with 116 additions and 112 deletions

View File

@ -180,7 +180,7 @@
</div> </div>
<div id="toggleButtons"> <div id="toggleButtons">
<div id="markDone" style="background-color:{{work 'doneCol'}}"> <div id="markDone" style="background-color:{{work 'doneCol'}}">
<i class="fa fa-check-square-o" aria-hidden="true"></i> <i class="fa {{work 'doneIcon'}}" aria-hidden="true"></i>
<p>{{work 'doneText'}}</p> <p>{{work 'doneText'}}</p>
</div> </div>
<div id="markConfirm" style="color:{{work 'userConfirm'}}"> <div id="markConfirm" style="color:{{work 'userConfirm'}}">
@ -188,7 +188,7 @@
<p>{{work 'confirmations'}}</p> <p>{{work 'confirmations'}}</p>
</div> </div>
<div id="markReport" style="color:{{work 'userReport'}}"> <div id="markReport" style="color:{{work 'userReport'}}">
<i class="fa fa-thumbs-down" aria-hidden="true"></i> <i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
<p>{{work 'reports'}}</p> <p>{{work 'reports'}}</p>
</div> </div>
<div class="workCreator doneUser" onclick="window.location='/user/{{work 'email'}}'"> <div class="workCreator doneUser" onclick="window.location='/user/{{work 'email'}}'">
@ -302,7 +302,7 @@
<div style="color:{{doneRatio}}"> <div style="color:{{doneRatio}}">
<i class="fa fa-thumbs-up" aria-hidden="true"></i> <i class="fa fa-thumbs-up" aria-hidden="true"></i>
<span>{{confirmationLength}}</span> <span>{{confirmationLength}}</span>
<i class="fa fa-thumbs-down" aria-hidden="true"></i> <i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
<span>{{reportLength}}</span> <span>{{reportLength}}</span>
</div> </div>
</div> </div>

View File

@ -282,16 +282,16 @@ Template.registerHelper('work', (value) => {// Returns the specified work value.
Template.main.helpers({ Template.main.helpers({
/*themeName() { /*themeName() {
var vals = _.values(themeColors); var vals = _.values(themeColors);
var curtheme = Session.get("user").preferences.theme; var curtheme = Session.get("user").preferences.theme;
for (var i = 0; i < vals.length; i++) { for (var i = 0; i < vals.length; i++) {
if (_.isEqual(vals[i], curtheme)) { if (_.isEqual(vals[i], curtheme)) {
var name = _.keys(themeColors)[i]; var name = _.keys(themeColors)[i];
return name.charAt(0).toUpperCase() + name.slice(1); return name.charAt(0).toUpperCase() + name.slice(1);
} }
} }
return "Custom"; return "Custom";
},*/ },*/
schoolName() { // Finds the name of the user's school. schoolName() { // Finds the name of the user's school.
if (Session.get("user").school === undefined || Session.get("user").school === null) return; if (Session.get("user").school === undefined || Session.get("user").school === null) return;
return " - " + Session.get("user").school; return " - " + Session.get("user").school;
@ -377,7 +377,7 @@ Template.main.helpers({
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) || Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
currClass.moderators.indexOf(Meteor.userId()) !== -1 || currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
currClass.banned.indexOf(Meteor.userId()) !== -1 currClass.banned.indexOf(Meteor.userId()) !== -1
) inRole = true; ) inRole = true;
events.push({ events.push({
id: work._id, id: work._id,
start: work.realDate.toISOString().slice(0, 10), start: work.realDate.toISOString().slice(0, 10),
@ -482,7 +482,7 @@ Template.main.helpers({
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) || Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
currClass.moderators.indexOf(Meteor.userId()) !== -1 || currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
currClass.banned.indexOf(Meteor.userId()) !== -1 currClass.banned.indexOf(Meteor.userId()) !== -1
) return true; ) return true;
} }
}, },
admin() { admin() {
@ -504,7 +504,7 @@ Template.main.events({
if (!(e.includes("optionHolder") || e.includes("optionText"))) { if (!(e.includes("optionHolder") || e.includes("optionText"))) {
if(document.getElementById(modifyingInput).className.includes("dropdown")) { if(document.getElementById(modifyingInput).className.includes("dropdown")) {
$(".optionHolder") $(".optionHolder")
.fadeOut(250, "linear"); .fadeOut(250, "linear");
$(".selectedOption").removeClass("selectedOption"); $(".selectedOption").removeClass("selectedOption");
} else { } else {
@ -626,9 +626,9 @@ Template.main.events({
_id: thisWork["class"] _id: thisWork["class"]
}); });
if (!(Meteor.userId() === thisWork.creator || // If user has permission. if (!(Meteor.userId() === thisWork.creator || // If user has permission.
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) || Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
currClass.moderators.indexOf(Meteor.userId()) !== -1 || currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
currClass.banned.indexOf(Meteor.userId()) !== -1)) { currClass.banned.indexOf(Meteor.userId()) !== -1)) {
var inputs = $('#editWork .clickModify').css("cursor", "default"); var inputs = $('#editWork .clickModify').css("cursor", "default");
} }
} }
@ -692,7 +692,7 @@ Template.main.events({
// HANDLING INPUT CHANGING // HANDLING INPUT CHANGING
'focus .clickModify' (event) { 'focus .clickModify' (event) {
$(".optionHolder") $(".optionHolder")
.fadeOut(250, "linear"); .fadeOut(250, "linear");
if(modifyingInput !== null) { if(modifyingInput !== null) {
if(!$("#"+modifyingInput)[0].className.includes("dropdown")) closeInput(modifyingInput); if(!$("#"+modifyingInput)[0].className.includes("dropdown")) closeInput(modifyingInput);
@ -745,12 +745,12 @@ Template.main.events({
$(".selectedOption").removeClass("selectedOption"); $(".selectedOption").removeClass("selectedOption");
$("#" + modifyingInput).next() $("#" + modifyingInput).next()
.css('opacity',0) .css('opacity',0)
.slideDown(300) .slideDown(300)
.animate( .animate(
{ opacity: 1 }, { opacity: 1 },
{ queue: false, duration: 100 } { queue: false, duration: 100 }
); );
}, },
'click .optionText' (event) { // Click each preferences setting. 'click .optionText' (event) { // Click each preferences setting.
var option = event.target.childNodes[0].nodeValue; var option = event.target.childNodes[0].nodeValue;
@ -761,7 +761,7 @@ Template.main.events({
serverData = Session.get("currentWork"); serverData = Session.get("currentWork");
$("#" + modifyingInput).next() $("#" + modifyingInput).next()
.fadeOut(250, "linear"); .fadeOut(250, "linear");
$(".selectedOption").removeClass("selectedOption"); $(".selectedOption").removeClass("selectedOption");
if(Session.get("newWork")) return; if(Session.get("newWork")) return;
if(checkMissing()) return; if(checkMissing()) return;
@ -780,7 +780,7 @@ Template.main.events({
} }
$("#" + modifyingInput).next() $("#" + modifyingInput).next()
.fadeOut(250, "linear"); .fadeOut(250, "linear");
$(".selectedOption").removeClass("selectedOption"); $(".selectedOption").removeClass("selectedOption");
}, },
@ -1030,82 +1030,86 @@ function toDate(date) { // Turns formatted date back to Date constructor.
function formReadable(input, val) { // Makes work information readable by users. function formReadable(input, val) { // Makes work information readable by users.
switch (val) { switch (val) {
case "typeColor": case "typeColor":
return input.typeColor = workColors[input.type]; return input.typeColor = workColors[input.type];
case "name": case "name":
return input.name; return input.name;
case "dueDate": case "dueDate":
return getReadableDate(input.dueDate); return getReadableDate(input.dueDate);
case "description": case "description":
return input.description; return input.description;
case "type": case "type":
return input.type[0].toUpperCase() + input.type.slice(1); return input.type[0].toUpperCase() + input.type.slice(1);
case "comments": case "comments":
var comments = input.comments; var comments = input.comments;
var resort = []; var resort = [];
if (Session.get("newWork")) return []; // Don't display comments if user is creating work. if (Session.get("newWork")) return []; // Don't display comments if user is creating work.
for (var k = 0; k < comments.length; k++) { for (var k = 0; k < comments.length; k++) {
var re = comments.length - k - 1; var re = comments.length - k - 1;
resort[re] = { resort[re] = {
"comment": comments[k].comment, "comment": comments[k].comment,
"date": null, "date": null,
"user": null, "user": null,
"avatar": null, "avatar": null,
"email": null "email": null
}; };
var user = Meteor.users.findOne({ var user = Meteor.users.findOne({
_id: comments[k].user _id: comments[k].user
}); });
resort[re].user = user.profile.name; resort[re].user = user.profile.name;
resort[re].date = moment(comments[k].date).fromNow(); resort[re].date = moment(comments[k].date).fromNow();
resort[re].avatar = user.services.google.picture; resort[re].avatar = user.services.google.picture;
resort[re].email = user.services.google.email; resort[re].email = user.services.google.email;
} }
return resort; return resort;
case "done": case "done":
if (Session.get("newWork")) return []; if (Session.get("newWork")) return [];
for (var i = 0; i < input.done.length; i++) { // Display users who marked as done. for (var i = 0; i < input.done.length; i++) { // Display users who marked as done.
var user = Meteor.users.findOne({ var user = Meteor.users.findOne({
_id: input.done[i] _id: input.done[i]
}); });
input.done[i] = { input.done[i] = {
"user": user.profile.name, "user": user.profile.name,
"avatar": user.services.google.picture, "avatar": user.services.google.picture,
"email": user.services.google.email "email": user.services.google.email
}; };
} }
return input.done; return input.done;
case "doneCol": case "doneCol":
if (Session.get("newWork")) return ""; if (Session.get("newWork")) return "";
if (!_.contains(input.done, Meteor.userId())) return ""; if (!_.contains(input.done, Meteor.userId())) return "";
return "#27A127"; return "#27A127";
case "doneText": case "doneText":
if (Session.get("newWork")) return ""; if (Session.get("newWork")) return "";
if (!_.contains(input.done, Meteor.userId())) return "Mark done"; if (!_.contains(input.done, Meteor.userId())) return "Mark done";
return "Done!"; return "Done!";
case "userConfirm": case "doneIcon":
if (!_.contains(input.confirmations, Meteor.userId())) return ""; if (Session.get("newWork")) return "";
return "#27A127"; if (!_.contains(input.done, Meteor.userId())) return "fa-square-o";
case "confirmations": return "fa-check-square-o";
return input.confirmations.length; case "userConfirm":
case "userReport": if (!_.contains(input.confirmations, Meteor.userId())) return "";
if (!_.contains(input.reports, Meteor.userId())) return ""; return "#27A127";
return "#FF1A1A"; case "confirmations":
case "reports": return input.confirmations.length;
return input.reports.length; case "userReport":
case "email": if (!_.contains(input.reports, Meteor.userId())) return "";
return Meteor.users.findOne({ return "#FF1A1A";
_id: input.creator case "reports":
}).services.google.email; return input.reports.length;
case "avatar": case "email":
return Meteor.users.findOne({ return Meteor.users.findOne({
_id: input.creator _id: input.creator
}).services.google.picture; }).services.google.email;
case "creator": case "avatar":
return Meteor.users.findOne({ return Meteor.users.findOne({
_id: input.creator _id: input.creator
}).profile.name; }).services.google.picture;
case "creator":
return Meteor.users.findOne({
_id: input.creator
}).profile.name;
} }
} }
@ -1116,12 +1120,12 @@ function startDragula() {
return _.intersection(["classInfo", "mainClassName", "mainClassHour", "mainClassTeacher"], handle.classList).length > 0; return _.intersection(["classInfo", "mainClassName", "mainClassHour", "mainClassTeacher"], handle.classList).length > 0;
} }
}) })
.on('out', function(el) { .on('out', function(el) {
var els = document.getElementsByClassName("classWrapper"); var els = document.getElementsByClassName("classWrapper");
var final = []; var final = [];
for (var i = 0; i < els.length; i++) { for (var i = 0; i < els.length; i++) {
var classid = els[i].getElementsByClassName("creWork")[0].getAttribute("classid"); var classid = els[i].getElementsByClassName("creWork")[0].getAttribute("classid");
final.push(classid); final.push(classid);
} }
}); });
} }