Code cleanup, and display formatting/css

This commit is contained in:
Kenneth Jao 2016-08-11 03:10:32 -04:00
parent 670e212543
commit e3444a8fc6
5 changed files with 164 additions and 351 deletions

View File

@ -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;
}

View File

@ -1,113 +1,64 @@
<head>
<title>Hourglass</title>
<link rel="icon" href="favicon.ico?v=2">
<title>Hourglass</title>
<link rel="icon" href="favicon.ico?v=2">
</head>
<body>
</body>
<template name="main">
<header style="background-color:{{divColor 'header'}}">
<div id="aboveBar">
<i class="fa fa-bars" aria-hidden="true" style="color:{{iconColor 'menu'}}"></i>
<h1>Hourglass</h1> <h2>{{schoolname}}</h2>
<i class="fa fa-cog" aria-hidden="true" style="color:{{iconColor 'options'}}"></i>
</div>
<div id="loadBar">
<div id="progress" style="background-color:{{loadType}};width:{{loadPercent}}"></div>
</div>
</header>
<div id="menuContainer" style="margin-left:{{menuStatus}};background-color:{{divColor 'sidebar'}}">
<div class="mode classes">
<i class="fa fa-university" aria-hidden="true"></i>
<h4 style="color:{{modeStatus 'classes'}}">Classes</h4>
</div>
<div class="mode calendar">
<i class="fa fa-calendar" aria-hidden="true"></i>
<h4 style="color:{{modeStatus 'calendar'}}">Calendar</h4>
</div>
<div id="functions">
<div class="function addClass">
<i class="fa fa-plus" aria-hidden="true"></i>
<h4 style="color:{{functionStatus 'addClass'}}">Join Class</h4>
</div>
<div class="function createClass">
<i class="fa fa-graduation-cap" aria-hidden="true"></i>
<h4 style="color:{{functionStatus 'creClass'}}">Create Class</h4>
</div>
<div class="function manageClass">
<i class="fa fa-tasks" aria-hidden="true"></i>
<h4 style="color:{{functionStatus 'manClass'}}">Manage Classes</h4>
</div>
</div>
<div id="functionHolder">
{{#if currFunction "addClass"}}
<p>Add a Class</p>
{{/if}}
{{#if currFunction "manClass"}}
<p>Manage Classes</p>
{{/if}}
{{#if currFunction "creClass"}}
<h2>Create a Class</h2>
<form id="create">
<p class="input">School:</p><br>
{{> inputAutocomplete settings=schoolcomplete class="form-control creInput" type="text" name="school" placeholder="Example: International Academy" }}
<p class="input">Hour:</p><br>
<input class="creInput" type="text" name="hour"><br>
<p class="input">Teacher:</p><br>
{{> inputAutocomplete settings=teachercomplete class="form-control creInput" type="text" name="teacher" placeholder="Example: Woods" }}
<p class="input">Class Name:</p><br>
<input class="creInput" type="text" name="classname"><br>
<p class="input">Privacy:</p><br>
<div class="select">
<input class="creInputSel creInput" type="text" name="privacy" op="0" readonly><br>
<div class="creOptions" style="background-color:{{divColor 'header'}}">
<p>Public</p>
<p>Private</p>
</div>
<header style="background-color:{{divColor 'header'}}">
<div id="aboveBar">
<i class="fa fa-bars" aria-hidden="true" style="color:{{iconColor 'menu'}}"></i>
<h1>Hourglass</h1><h2>{{schoolName}}</h2>
<i class="fa fa-cog" aria-hidden="true" style="color:{{iconColor 'options'}}"></i>
</div>
<div id="loadBar">
<div id="progress" style="background-color:{{loadType}};width:{{loadPercent}}"></div>
</div>
</header>
<div id="menuContainer" style="margin-left:{{menuStatus}};background-color:{{divColor 'sidebar'}}">
<div class="mode classes">
<i class="fa fa-university" aria-hidden="true"></i>
<h4 style="color:{{modeStatus 'classes'}}">Classes</h4>
</div>
<div class="mode calendar">
<i class="fa fa-calendar" aria-hidden="true"></i>
<h4 style="color:{{modeStatus 'calendar'}}">Calendar</h4>
</div>
<div id="functions">
<div class="function manageClass" onclick="window.location='/profile'">
<i class="fa fa-tasks" aria-hidden="true"></i>
<h4>Manage Classes</h4>
</div>
<p class="input">Category:</p><br>
<div class="select">
<input class="creInputSel creInput" type="text" name="category" op="1" readonly><br>
<div class="creOptions" style="background-color:{{divColor 'header'}}">
<p>Class</p>
<p>Club</p>
<p>Other</p>
</div>
</div>
<div class="creSubmit">Submit Request</div>
</form>
{{/if}}
</div>
</div>
<div id="optionsContainer" style="margin-right:{{optionsStatus}};background-color:{{divColor 'sidebar'}}">
</div>
<img id="bg" src={{bgSrc}}>
<div id="mainBody">
{{#if currMode 'classes'}}
{{/if}}
{{#if currMode 'calendar'}}
<div id="calendar" style="{{calCenter}}">
{{> fullcalendar calendarOptions id="fullcalendar"}}
</div>
<div id="classListHolder">
</div>
</div>
{{/if}}
</div>
<div class="overlay">
<div class="overlayCont" style="{{overlayDim}};">
<p>Are you sure?</p>
<i class="fa fa-check-circle-o" aria-hidden="true"></i>
<i class="fa fa-times-circle-o" aria-hidden="true"></i>
<div id="optionsContainer" style="margin-right:{{optionsStatus}};background-color:{{divColor 'sidebar'}}">
</div>
<img id="bg" src={{bgSrc}}>
<div id="mainBody">
{{#if currMode 'classes'}}
{{/if}}
{{#if currMode 'calendar'}}
<div id="calbg" style="{{calbg}}"></div>
<div id="calendar" style="{{calCenter}}">
{{> fullcalendar calendarOptions id="fullcalendar"}}
</div>
{{/if}}
</div>
<div class="overlay">
<div class="overlayCont" style="{{overlayDim}};">
<p>Are you sure?</p>
<i class="fa fa-check-circle-o" aria-hidden="true"></i>
<i class="fa fa-times-circle-o" aria-hidden="true"></i>
</div>
</div>
</div>
</template>
<template name="schoollist">
{{name}}
{{name}}
</template>
<template name="teacherlist">
{{teacher}}
{{teacher}}
</template>

View File

@ -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);
},
'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);
}
}
});

View File

@ -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")]);
}
},

View File

@ -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}});