update
This commit is contained in:
1 parent
be398bf5ce
commit
f121eff445
38 files changed
+498
-267
No files matched your search
+19
-4
@@ -210,10 +210,25 @@ app.config(($locationProvider, $routeProvider) => {
|
||||
});
|
||||
|
||||
app.run(($location, $rootScope, $http) => {
|
||||
$rootScope.$on('$routeChangeSuccess', (event, current) => {
|
||||
let title = current['$$route'].title;
|
||||
if (title) $rootScope.title = title;
|
||||
});
|
||||
$rootScope.$on('$routeChangeSuccess', (event, current) => {
|
||||
const url = location.href;
|
||||
const title = current['$$route'].title;
|
||||
|
||||
if (title) $rootScope.title = title;
|
||||
|
||||
setTimeout(() => {
|
||||
try {
|
||||
DISQUS.reset({
|
||||
reload: true,
|
||||
config: function () {
|
||||
this.page.identifier = url;
|
||||
this.page.url = url;
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
}, 500)
|
||||
});
|
||||
|
||||
$rootScope.$on('$routeChangeError', (event, current) => {
|
||||
//let title = current['$$route'].title;
|
||||
|
||||
@@ -1,46 +1,41 @@
|
||||
import template from '../../templates/components/page-schedule.html';
|
||||
import APISchedule from '../api/APISchedule';
|
||||
import {populate} from '../../utils/populate';
|
||||
import {getCourseNameByID} from '../../models/course';
|
||||
import {indexEquals} from '../../utils/common';
|
||||
import {select, choise} from '../../utils/common';
|
||||
|
||||
export default function (app) {
|
||||
app.component('pageSchedule', {
|
||||
template: template,
|
||||
bindings: {
|
||||
//currentSchedule: '<',
|
||||
schedules: '<'
|
||||
},
|
||||
controller: function($http, $location, $routeParams, api, menu) {
|
||||
this.pageClass = 'page-schedule';
|
||||
menu.activate('/schedule');
|
||||
|
||||
const period = $routeParams.period;
|
||||
const semester = $routeParams.semester;
|
||||
const useRoute = period && semester;
|
||||
const useRoute = Boolean(period) && Boolean(semester);
|
||||
|
||||
this.loadSchedule = (record, doUpdateURL) => {
|
||||
const stringPeriod = period => period.join('-');
|
||||
|
||||
this.loadSchedule = (record, doUpdateUrl) => {
|
||||
let id = record._id;
|
||||
let scheduleItem = getScheduleByID(id);
|
||||
let scheduleItem = getScheduleById(id);
|
||||
if (scheduleItem) {
|
||||
let p = scheduleItem.period;
|
||||
let p = scheduleItem.period.join('-');
|
||||
let s = scheduleItem.semester;
|
||||
api.schedule.fetch(p, s, true)
|
||||
.then(i => i.data)
|
||||
.then(i => {
|
||||
this.schedule = i.schedule;
|
||||
if (doUpdateURL) $location.url(APISchedule.buildScheduleUrl(p, s));
|
||||
this.schedule = i;
|
||||
if (doUpdateUrl) $location.url(APISchedule.buildScheduleUrl(p, s));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let getScheduleByID = id => this.schedules
|
||||
const getScheduleById = id => this.schedules
|
||||
.find(i => i._id === id);
|
||||
|
||||
let getRoutedSchedule = list => {
|
||||
return list.find(i => i.period === period && i.semester === semester)
|
||||
};
|
||||
const getSchedule = (period, semester) => this.schedules
|
||||
.find(i => stringPeriod(i.period) === period && i.semester === semester);
|
||||
|
||||
let last = list => list.length ? list[list.length - 1] : null;
|
||||
let getDefaultSchedule = list => last(list);
|
||||
@@ -51,12 +46,12 @@ export default function (app) {
|
||||
|
||||
this.schedules.forEach(i => {
|
||||
let periodIndex = i.semester === 'spring' ? 1 : 0;
|
||||
let year = i.period.split('-')[periodIndex];
|
||||
let year = i.period[periodIndex];
|
||||
i.text = `${word(i.semester)} ${year} года`;
|
||||
});
|
||||
this.currentSchedule = useRoute ? getRoutedSchedule(this.schedules) : getDefaultSchedule(this.schedules);
|
||||
|
||||
this.loadSchedule(this.currentSchedule, useRoute);
|
||||
this.currentSchedule = useRoute ? getSchedule(period, semester) : getDefaultSchedule(this.schedules);
|
||||
if(this.currentSchedule) this.loadSchedule(this.currentSchedule, useRoute);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -36,21 +36,14 @@ export default function (app) {
|
||||
return Math.min(max, Math.max(min, value));
|
||||
};
|
||||
|
||||
return value => fit ?
|
||||
constrain(map_range(value, r1, r2, d1, d2))
|
||||
:
|
||||
map_range(value, r1, r2, d1, d2)
|
||||
return value => fit ? constrain(map_range(value, r1, r2, d1, d2)) : map_range(value, r1, r2, d1, d2);
|
||||
}
|
||||
|
||||
let hm = mapper([0, 900], [0, 900], true);
|
||||
let em = mapper([340, 900], [0, 400], true);
|
||||
//let pm = mapper([0, 1000], [1000, 900], true);
|
||||
const hm = mapper([0, 900], [0, 900], true);
|
||||
const em = mapper([340, 900], [0, 400], true);
|
||||
|
||||
function updateHead(value) {
|
||||
//console.log(value);
|
||||
|
||||
let v = hm(value);
|
||||
//let v = value;
|
||||
const v = hm(value);
|
||||
|
||||
try {
|
||||
[...document.querySelectorAll('.parallax .parallax__layer')]
|
||||
@@ -59,15 +52,9 @@ export default function (app) {
|
||||
e.style.top = `${layer.y + v * layer.s}px`;
|
||||
});
|
||||
|
||||
let end = document.querySelector('.parallax .parallax__end');
|
||||
end.style.height = `${em(value)}px`;
|
||||
|
||||
//let container = document.querySelector('.parallax');
|
||||
//container.style.height = '1000px';
|
||||
//container.style.height = `${pm(value)}px`;
|
||||
|
||||
const end = document.querySelector('.parallax .parallax__end');
|
||||
if (end) end.style.height = `${em(value)}px`;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +64,5 @@ export default function (app) {
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import template from '../../templates/components/schedule-record.html';
|
||||
import {shortName} from '../../models/collective';
|
||||
import {nullSafe} from "../../utils/common";
|
||||
|
||||
export default function(app) {
|
||||
app.component('scheduleRecord', {
|
||||
@@ -6,6 +8,9 @@ export default function(app) {
|
||||
record: '<',
|
||||
i: '<'
|
||||
},
|
||||
template: template
|
||||
template: template,
|
||||
controller: function() {
|
||||
this.short = nullSafe(shortName);
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -11,13 +11,11 @@ function week(schedule) {
|
||||
current: i === now.getDay() - 1,
|
||||
day: day,
|
||||
date: dates[i],
|
||||
groups: schedule.map(group => {
|
||||
return {
|
||||
name: group.group,
|
||||
time: group.time,
|
||||
content: group.week[i]
|
||||
}
|
||||
})
|
||||
groups: schedule.groups.map(group => ({
|
||||
name: group.group,
|
||||
time: group.time,
|
||||
content: group.week[i]
|
||||
}))
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -41,7 +39,7 @@ export default function(app) {
|
||||
}
|
||||
|
||||
if (value) {
|
||||
let days = week(value);
|
||||
const days = week(value);
|
||||
scope.days = days;
|
||||
|
||||
$slick.html(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import template from '../../templates/components/schedule-table.html';
|
||||
import {getDates} from '../../utils/date';
|
||||
import {shortName} from '../../models/collective';
|
||||
|
||||
export default function(app) {
|
||||
app.component('scheduleTable', {
|
||||
@@ -11,8 +12,10 @@ export default function(app) {
|
||||
const now = new Date();
|
||||
const dates = getDates(now);
|
||||
|
||||
this.days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
||||
this.isToday = weekDayIndex => (now.getDay() - 1) === weekDayIndex;
|
||||
this.weekDay = weekDayIndex => dates[weekDayIndex];
|
||||
this.short = shortName;
|
||||
|
||||
//var $tbody = element.find('table tbody');
|
||||
//var $thead = element.find('table thead');
|
||||
|
||||
@@ -46,7 +46,7 @@ import {createInstance as createInstagram} from '../../models/TimelinePostInstag
|
||||
const createPost = post => post.type === 'post' ? post : null;
|
||||
const createPosts = items => items
|
||||
.map(createRecord)
|
||||
.filter(i => i);
|
||||
.filter(Boolean);
|
||||
|
||||
function createRecord(post){
|
||||
for (let fn of [createInstagram, createPost]){
|
||||
|
||||
Reference in new issue
Block a user