From e3444a8fc64afb1322ead5dbf0db315bfeb2de8c Mon Sep 17 00:00:00 2001 From: Kenneth Jao Date: Thu, 11 Aug 2016 03:10:32 -0400 Subject: [PATCH] Code cleanup, and display formatting/css --- hourglass/client/main/main.css | 108 +++------------ hourglass/client/main/main.html | 149 +++++++------------- hourglass/client/main/main.js | 208 ++++++++-------------------- hourglass/client/profile/profile.js | 9 +- hourglass/server/main.js | 41 ++++-- 5 files changed, 164 insertions(+), 351 deletions(-) diff --git a/hourglass/client/main/main.css b/hourglass/client/main/main.css index 94dae5a..3964e9a 100644 --- a/hourglass/client/main/main.css +++ b/hourglass/client/main/main.css @@ -204,7 +204,7 @@ input { z-index: 1; } -#functionHolder { +#classListHolder { max-height: 48%; width: 90%; margin-bottom: 30%; @@ -222,90 +222,6 @@ input { transition: opacity 0.4s ease; } -#create { - font-size: 140%; - width: 100%; -} - -.input { - margin: 0; - margin-top: 3%; - margin-bottom: -9%; - - -webkit-filter: drop-shadow(2px 2px 5px #666); - filter: drop-shadow(2px 2px 5px #666); -} - -.creSubmit { - width: 100%; - margin-top: 30%; - padding: 3% 0 3% 0; - text-align: center; - background-color: #849CAE; - - -webkit-transition: background-color 0.5s ease; - -moz-transition: background-color 0.5s ease; - -ms-transition: background-color 0.5s ease; - transition: background-color 0.5s ease; - - cursor: pointer; -} - -.creSubmit:hover { - background-color: #A2B5C3; -} - -.creSubmit:active { - background-color: #EFF3F5; - - -webkit-transition: background-color 0.2s ease; - -moz-transition: background-color 0.2s ease; - -ms-transition: background-color 0.2s ease; - transition: background-color 0.2s ease; -} - -.creInput, select { - font-family: 'Raleway'; - width: 90%; - margin-bottom: 4%; - padding: 3.5%; - - position: relative; - z-index: 0; -} - -select { - font-family: 'Raleway'; - width: 100%; -} - -.creOptions { - width: 80%; - margin-top: -3.4%; - - box-shadow: 2px 2px 5px 3px #666; - - display: none; - position: absolute; - z-index: 5; - opacity: 0; - - -webkit-transition: opacity 0.4s ease; - -moz-transition: opacity 0.4s ease; - -ms-transition: opacity 0.4s ease; - transition: opacity 0.4s ease; -} - -.creOptions p { - margin: 0; - padding: 5%; - display: block; -} - -.creOptions p:hover { - box-shadow: inset 0 0 0 99999px rgba(0,0,0,0.1) -} - .overlay { width: 100%; height: 100%; @@ -409,6 +325,18 @@ select { height: 100%; } +#calbg { + background-color: rgba(255,255,255,0.3); + position: absolute; +} + +.fc-view-container, .fc-left { + -webkit-transition: opacity 0.4s ease; + -moz-transition: opacity 0.4s ease; + -ms-transition: opacity 0.4s ease; + transition: opacity 0.4s ease; +} + .fc-view-container { background-color: rgba(255,255,255,0.8); } @@ -417,13 +345,16 @@ select { padding: 0.5% 1% 0.5% 1%; background-color: rgba(255,255,255,0.8); - -moz-border-radius: 10px; - -webkit-border-radius: 10px; - border-radius: 10px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; } .fc-left h2 { font-weight: 400; + + -webkit-filter: none; + filter: none; } .fc-head { @@ -446,5 +377,4 @@ select { .fc-button:hover { background-color: rgba(255,255,255,0.9) !important; - } \ No newline at end of file diff --git a/hourglass/client/main/main.html b/hourglass/client/main/main.html index 14a90a7..5139925 100644 --- a/hourglass/client/main/main.html +++ b/hourglass/client/main/main.html @@ -1,113 +1,64 @@ - Hourglass - + Hourglass + - - - - \ No newline at end of file diff --git a/hourglass/client/main/main.js b/hourglass/client/main/main.js index 2f86ff0..de0e6a5 100644 --- a/hourglass/client/main/main.js +++ b/hourglass/client/main/main.js @@ -33,13 +33,8 @@ var options = { var searchSchools = []; -Session.set("menuOpen", false); -Session.set("optionsOpen", false); +Session.set("sidebar",null); Session.set("mode",null); // Change to user preferences -Session.set("function", null); -Session.set("confirm",null); -Session.set("formCre",null); -Session.set("inputOpen",null); Template.registerHelper( 'divColor', (div) => { return themeColors[Cookie.get("theme")][div]; @@ -55,12 +50,13 @@ Template.registerHelper( 'overlayDim', (part) => { }) Template.main.helpers({ - schoolname() { + schoolName() { return " - " + Meteor.user().profile.school; }, iconColor(icon) { - let status = Session.get(icon+"Open"); - if(status) { + if(Session.get("sidebar") === icon+"Container") { + return themeColors[Cookie.get("theme")].statusIcons; + } else if(Session.get("sidebar") === "both") { return themeColors[Cookie.get("theme")].statusIcons; } else { return; @@ -72,13 +68,23 @@ Template.main.helpers({ return pic; }, menuStatus() { - let status = Session.get("menuOpen"); - if(status) { + if(Session.get("sidebar") === "menuContainer") { + return "0%"; + } else if(Session.get("sidebar") === "both") { return "0%"; } else { return openValues["menu"]; } }, + optionsStatus() { + if(Session.get("sidebar") === "optionsContainer") { + return "0%"; + } else if(Session.get("sidebar") === "both") { + return "0%"; + } else { + return openValues["options"]; + } + }, modeStatus(status) { if(status === Session.get("mode")) { return themeColors[Cookie.get("theme")].highlightText; @@ -86,13 +92,6 @@ Template.main.helpers({ return; } }, - functionStatus(status) { - if(status === Session.get("function")) { - return themeColors[Cookie.get("theme")].highlightText; - } else { - return; - } - }, currMode(name) { if(name === Session.get("mode")) { return true; @@ -100,57 +99,6 @@ Template.main.helpers({ return false; } }, - currFunction(name) { - if(name === Session.get("function")) { - return true; - } else { - return false; - } - }, - optionsStatus() { - let status = Session.get("optionsOpen"); - if(status) { - return "0%"; - } else { - return openValues["options"]; - } - }, - creHighlight(input) { - if(input == Session.get("creInput")) { - return "#CCEEFF"; - } else { - return; - } - }, - schoolcomplete() { - return { - position: "bottom", - limit: 6, - rules: [ - { - token: '', - collection: schools, - field: 'name', - matchAll: true, - template: Template.schoollist - } - ] - }; - }, - teachercomplete() { - return { - position: "bottom", - limit: 1, - rules: [ - { - token: '', - collection: classes, - field: 'teacher', - template: Template.teacherlist - } - ] - }; - }, calendarOptions() { var cursor = work.find({}); var events = []; @@ -160,35 +108,64 @@ Template.main.helpers({ duedate = current.dueDate.toISOString().slice(0,10); events.push({start: duedate, title: title, backgroundColor: backgroundColor}); }); - console.log(events); return { height: window.innerHeight *.8, - events: events + events: events, + buttonText: { + today: 'Today', + month: 'Month', + week: 'Week', + day: 'Day' + } }; }, calCenter() { var width = window.innerWidth * .85; return "width:"+width.toString()+"px;margin-left:"+(.5*window.innerWidth-.5*width).toString()+"px"; + }, + calbg() { + var width = window.innerWidth * .865; + var height = window.innerHeight * .76; + return "width:"+width.toString()+"px;height:"+height.toString()+"px;margin-left:"+(.5*window.innerWidth-.5*width).toString()+"px;margin-top:"+(.47*window.innerHeight-.5*height).toString()+"px"; } }); Template.main.events({ 'click .fa-bars' () { - Session.set("menuOpen",!Session.get("menuOpen")); + var side = Session.get("sidebar"); + if(side === "menuContainer") { + Session.set("sidebar",null) + } else if(side === "optionsContainer") { + Session.set("sidebar","both"); + } else if(side === "both") { + Session.set("sidebar","optionsContainer"); + } else { + Session.set("sidebar","menuContainer"); + } }, 'click .fa-cog' () { - Session.set("optionsOpen",!Session.get("optionsOpen")); + var side = Session.get("sidebar"); + if(side === "optionsContainer") { + Session.set("sidebar",null) + } else if(side === "menuContainer") { + Session.set("sidebar","both"); + } else if(side === "both") { + Session.set("sidebar","menuContainer"); + } else { + Session.set("sidebar","optionsContainer"); + } }, 'click .classes' () { + if(Session.get("mode") === "classes") return; var modeHolder = document.getElementById("mainBody"); closeDivFade(modeHolder); setTimeout(function() { Session.set("mode","classes"); openDivFade(modeHolder); - }, 300); - + }, 300); }, 'click .calendar' () { + if(Session.get("mode") === "calendar") return; var modeHolder = document.getElementById("mainBody"); closeDivFade(modeHolder); setTimeout(function() { @@ -196,83 +173,14 @@ Template.main.events({ openDivFade(modeHolder); }, 300); }, - 'click .addClass' () { - var functionHolder = document.getElementById("functionHolder") - closeDivFade(functionHolder); - setTimeout(function() { - Session.set("function","addClass"); - openDivFade(functionHolder); - },300); - }, - 'click .manageClass' () { - var functionHolder = document.getElementById("functionHolder") - closeDivFade(functionHolder); - setTimeout(function() { - Session.set("function","manClass"); - openDivFade(functionHolder); - },300); - }, - 'click .createClass' () { - var functionHolder = document.getElementById("functionHolder") - closeDivFade(functionHolder); - setTimeout(function() { - Session.set("function","creClass"); - openDivFade(functionHolder); - },300); - }, - 'click .creSubmit' () { - openDivFade(document.getElementsByClassName("overlay")[0]); - setTimeout(function() { - document.getElementsByClassName("overlay")[0].style.opacity = "1"; - }, 200); - Session.set("confirm","createClass"); - }, - 'click .fa-check-circle-o' () { - sendData(); - closeDivFade(document.getElementsByClassName("overlay")[0]); - closeDivFade(document.getElementById("functionHolder")); - document.getElementById("create").reset(); - setTimeout(function() { - Session.set("confirm",null); - Session.set("function",null); - }, 300); - }, - 'click .fa-times-circle-o' () { - closeDivFade(document.getElementsByClassName("overlay")[0]); - closeDivFade(document.getElementById("functionHolder")); - document.getElementById("create").reset(); - setTimeout(function() { - Session.set("confirm",null); - Session.set("function",null); - }, 300); - }, - 'click .creInput' (event) { - var opened = Session.get("inputOpen"); - if(opened !== null && opened !== event.target.getAttribute("op")) { - closeDivFade(document.getElementsByClassName("creInputSel")[opened].parentNode.childNodes[4]); - } - }, - 'click .creInputSel' (event) { - Session.set("inputOpen", event.target.getAttribute("op")); - openDivFade(event.target.parentNode.childNodes[4]); - }, - 'focus .creInputSel' (event) { - Session.set("inputOpen", event.target.getAttribute("op")); - openDivFade(event.target.parentNode.childNodes[4]); - }, - 'click .creOptions p' (event) { - var p = event.target; - p.parentNode.parentNode.childNodes[1].value = p.childNodes[0].nodeValue; - closeDivFade(p.parentNode); - p.parentNode.parentNode.childNodes[1].focus(); - Session.set("inputOpen",null) - }, 'click' (event) { var e = event.target.className; - if(!(e.includes("creInput") || e.includes("select"))) { - try { - closeDivFade(document.getElementsByClassName("creInputSel")[Session.get("inputOpen")].parentNode.childNodes[4]); - } catch(err) {} + if(e !== Session.get("sidebar") && + !e.includes("fa-cog") && + !e.includes("fa-bars") && + !document.getElementById("menuContainer").contains(event.target) && + !document.getElementById("optionsContainer").contains(event.target)) { + Session.set("sidebar", null); } } }); diff --git a/hourglass/client/profile/profile.js b/hourglass/client/profile/profile.js index c5beeca..afee9f6 100644 --- a/hourglass/client/profile/profile.js +++ b/hourglass/client/profile/profile.js @@ -213,10 +213,15 @@ Template.profile.events({ }, 'click' (event) { var sessval = Session.get("modifying"); - if(event.target.id !== sessval && event.target.id !== sessval+"a" && !Session.equals("modifying",null) && !event.target.parentNode.className.includes("profOptions")) { + if(event.target.id !== sessval && + event.target.id !== sessval+"a" && + !Session.equals("modifying",null) && + !event.target.parentNode.className.includes("profOptions")) { closeInput(sessval); } - if(!event.target.className.includes("radio") && !Session.equals("radioDiv",null) && !event.target.parentNode.className.includes("profOptions")) { + if(!event.target.className.includes("radio") && + !Session.equals("radioDiv",null) && + !event.target.parentNode.className.includes("profOptions")) { closeDivFade(document.getElementsByClassName("profOptions")[Session.get("radioDiv")]); } }, diff --git a/hourglass/server/main.js b/hourglass/server/main.js index ee33b8a..8d94251 100644 --- a/hourglass/server/main.js +++ b/hourglass/server/main.js @@ -13,8 +13,9 @@ Meteor.methods({ }, 'createSchool': function(schoolname) { // if superadmin, no need for approval - if (Meteor.user() != null && schools.findOne({name:input.school}) != null && - schools.findOne({status: false, creator: Meteor.userId()}) != null) { + if (Meteor.user() != null && + schools.findOne({name:input.school}) != null && + schools.findOne({status: false, creator: Meteor.userId()}) != null) { schools.insert({name: schoolname, status: false, creator: Meteor.userId()}); } @@ -26,8 +27,10 @@ Meteor.methods({ 'createClass': function(input) { // if superadmin, no need for approval classes.schema.validate(input); - if(Meteor.user() != null && classes.find({status:false, admin:Meteor.userId()}).fetch().length < 5 && - schools.findOne({name:input.school}) != null) { + if(Meteor.user() != null && + classes.find({status:false, admin:Meteor.userId()}).fetch().length < 5 && + schools.findOne({name:input.school}) != null) { + input.status = false; input.subscribers = 0; input.admin = Meteor.userId() @@ -64,9 +67,15 @@ Meteor.methods({ ref = new Date(ref.getFullYear()+ "-" + month.toString() + "-" + ref.getDate()).getTime() work.schema.validate(input); found = Meteor.findOne({_id: input.class}) - if (Meteor.user() != null && found != null && found.subscribers.indexOf(Meteor.userId()) != -1 - && found.banned.indexOf(Meteor.userId()) === -1 && found.blockEdit.indexOf(Meteor.userId()) === -1 - && input.dueDate.getTime() >= ref && worktype.indexOf(type) != -1 && input.name.length <= 50) { + + if (Meteor.user() != null && + found != null && + found.subscribers.indexOf(Meteor.userId()) != -1 && + found.banned.indexOf(Meteor.userId()) === -1 && + found.blockEdit.indexOf(Meteor.userId()) === -1 && + input.dueDate.getTime() >= ref && worktype.indexOf(type) != -1 && + input.name.length <= 50) { + input.submittor = Meteor.userId(); input.confirmations = [Meteor.userId()]; input.reports = []; @@ -87,8 +96,13 @@ Meteor.methods({ current.description = change[2]; current.avatar = change[3]; current.banner = change[4]; - if (schools.findOne({name:current.school}) != null && Number.isInteger(current.grade) && - current.grade >= 9 && current.grade <= 12 && current.description.length <= 50) { + + if (schools.findOne({name:current.school}) != null && + Number.isInteger(current.grade) && + current.grade >= 9 && + current.grade <= 12 && + current.description.length <= 50) { + Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}}); return 1; } else { @@ -97,8 +111,13 @@ Meteor.methods({ }, 'joinClass': function(change, pass) { found = classes.findOne({_id: change, status: true}); - if (Meteor.user() != null && found != null && pass === found.code - && found.banned.indexOf(Meteor.userId()) === -1 && Meteor.user().profile.classes.indexOf(change) === -1) { + + if (Meteor.user() != null && + found != null && + pass === found.code && + found.banned.indexOf(Meteor.userId()) === -1 && + Meteor.user().profile.classes.indexOf(change) === -1) { + current = Meteor.user().profile; current.classes.append(change); Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});