Minor bug fixes

This commit is contained in:
Kenneth Jao 2016-10-19 01:24:14 -04:00
parent bf025fd1a7
commit 57cacea42a
4 changed files with 41 additions and 11 deletions

View File

@ -779,6 +779,10 @@ textarea.clickModify {
display: inline-block; display: inline-block;
} }
#typeWrapper .optionText:hover {
box-shadow: inset 0 0 0 99999px rgba(0,0,0,0.2);
}
.datepicker { .datepicker {
box-shadow: 2px 2px 5px 3px #666; box-shadow: 2px 2px 5px 3px #666;
color: #000; color: #000;

View File

@ -274,7 +274,7 @@ Template.registerHelper('work', (value) => {// Returns the specified work value.
var thisWork = Session.get("currentWork"); var thisWork = Session.get("currentWork");
if (Session.equals("currentWork", null)) return; if (Session.equals("currentWork", null)) return;
if (Session.get("newWork") && (thisWork[value] === true || thisWork[value] === undefined)) { if (Session.get("newWork") && (thisWork[value] === true || thisWork[value] === undefined)) {
return (value === "dueDate") ? getReadableDate(new Date((new Date()).valueOf() + 1000*3600*24)) : defaultWork[value]; return defaultWork[value];
} else { } else {
return formReadable(thisWork,value); return formReadable(thisWork,value);
} }
@ -532,11 +532,10 @@ Template.main.events({
if (e === "overlay") { // Overlay closing. if (e === "overlay") { // Overlay closing.
closeDivFade(document.getElementsByClassName("overlay")[0]); closeDivFade(document.getElementsByClassName("overlay")[0]);
Session.set("newWork",false);
if (!Session.get("newWork")) { if (!Session.get("newWork")) {
document.getElementById("workComment").value = ""; document.getElementById("workComment").value = "";
} }
$('.req').css("color", "");
Session.set("commentRestrict", null);
} }
if (!document.getElementById("userDropdown").contains(event.target)) closeDivFade(document.getElementById("userDropdown")); if (!document.getElementById("userDropdown").contains(event.target)) closeDivFade(document.getElementById("userDropdown"));
@ -601,7 +600,7 @@ Template.main.events({
attr = event.target.getAttribute("classid"); attr = event.target.getAttribute("classid");
} }
Session.set("newWork", true); Session.set("newWork", true);
Session.set("currentWork",{class: attr}); Session.set("currentWork",{class: attr, dueDate: (new Date((new Date()).valueOf() + 1000*3600*24))});
openDivFade(document.getElementsByClassName("overlay")[0]); openDivFade(document.getElementsByClassName("overlay")[0]);
}, },
'click #dropdown' (event) { 'click #dropdown' (event) {
@ -760,7 +759,12 @@ Template.main.events({
newSetting[modifyingInput.charAt(1).toLowerCase() + modifyingInput.slice(2)] = option.toLowerCase(); newSetting[modifyingInput.charAt(1).toLowerCase() + modifyingInput.slice(2)] = option.toLowerCase();
Session.set("currentWork", newSetting); Session.set("currentWork", newSetting);
serverData = Session.get("currentWork"); serverData = Session.get("currentWork");
if(checkMissing() || Session.get("newWork")) return;
$("#" + modifyingInput).next()
.fadeOut(250, "linear");
$(".selectedOption").removeClass("selectedOption");
if(Session.get("newWork")) return;
if(checkMissing()) return;
sendData("editWork") sendData("editWork")
} else { } else {
var newSetting = Session.get("user"); var newSetting = Session.get("user");
@ -776,7 +780,7 @@ Template.main.events({
} }
$("#" + modifyingInput).next() $("#" + modifyingInput).next()
.fadeOut(250, "linear");; .fadeOut(250, "linear");
$(".selectedOption").removeClass("selectedOption"); $(".selectedOption").removeClass("selectedOption");
}, },
@ -931,6 +935,11 @@ function closeDivFade(div) {
} }
function sendData(funcName) { // Call Meteor function, and do actions after function is completed depending on function. function sendData(funcName) { // Call Meteor function, and do actions after function is completed depending on function.
if(funcName === "editWork" || funcName === "createWork") {
for(var key in serverData) {
if(serverData[key] === true) serverData[key] = "";
}
}
Meteor.call(funcName, serverData, function(error, result) { Meteor.call(funcName, serverData, function(error, result) {
serverData = null; serverData = null;
currWork = Session.get("currentWork"); currWork = Session.get("currentWork");
@ -971,17 +980,27 @@ function getHomeworkFormData() { // Get all data relating to work creation.
} }
})(); })();
// True signifies missing field to prevent missing if value is'Missing field.' // True signifies missing field to prevent missing if value is'Missing field.'
data[title] = (thisData.toString().includes(defaultWork[title].slice(0,-3)) && !_.contains(optional, title)) ? true : thisData; data[title] = data[title] = (thisData.toString().includes(defaultWork[title].slice(0,-3)) && !_.contains(optional, title)) ? true : thisData;
} }
return data; return data;
} }
function checkMissing() { function checkMissing() {
var required = ["name","dueDate","type"]
var no = false; var no = false;
if(serverData === null || Object.keys(serverData).length < 4) {
for(var i = 0; i < required.length; i++) {
var id = "w" + required[i].charAt(0).toUpperCase() + required[i].slice(1);
$("#"+id).addClass("formInvalid");
$("#"+id)[0].value = "";
$("#"+id)[0].placeholder = "Missing field";
}
return true;
}
for(var key in serverData) { for(var key in serverData) {
if(!_.contains(["name","dueDate","type"],key)) continue; if(!_.contains(required, key)) continue;
var id = "w" + key.charAt(0).toUpperCase() + key.slice(1); var id = "w" + key.charAt(0).toUpperCase() + key.slice(1);
if(serverData[key] === true || serverData[key] === "") { if(serverData[key] === true || serverData[key] === "" || serverData[key] === undefined) {
no = true; no = true;
$("#"+id).addClass("formInvalid"); $("#"+id).addClass("formInvalid");
$("#"+id)[0].value = ""; $("#"+id)[0].value = "";

View File

@ -588,6 +588,13 @@ Template.profile.events({
Session.set("autocompleteDivs", divs); Session.set("autocompleteDivs", divs);
} }
} catch (err) {} } catch (err) {}
},
'mouseenter .optionText' (event) {
console.log("hi");
event.target.className += " selectedOption";
},
'mouseleave .optionText' (event) {
event.target.className.replace(" selectedOption", "");
} }
}); });

View File

@ -103,8 +103,8 @@ options = {
{"val": "other", "alias": "Other"}, {"val": "other", "alias": "Other"},
], ],
"privacy": [ "privacy": [
{"val": true, "alias": "Private"}, {"val": false, "alias": "Public"},
{"val": false, "alias": "Public"} {"val": true, "alias": "Private"}
], ],
"category": [ "category": [
{"val": "class", "alias": "Class"}, {"val": "class", "alias": "Class"},