Compare commits

...

38 Commits

Author SHA1 Message Date
Hykilpikonna 24befed17b [U] Pre-Release v0.3.6.741 2019-10-20 22:00:35 -04:00
Hykilpikonna 07991b2a0e [F] Update title after history 2019-10-20 21:59:11 -04:00
Hykilpikonna 51ea0c7a80 [+] Update title when updating history 2019-10-20 21:56:00 -04:00
Hykilpikonna 8b01428208 [+] Create function to find title 2019-10-20 21:55:39 -04:00
Hykilpikonna f69e2617d4 [+] Encapsulate toTitleCase() 2019-10-20 21:55:13 -04:00
Hykilpikonna ddfdb47b93 [+] Encapsulate findCourse 2019-10-20 21:49:51 -04:00
Hykilpikonna 14849f4211 [O] Move updateIndex logging to a better place 2019-10-20 21:42:44 -04:00
Hykilpikonna 067c599cb1 [F] Fix history pop state override issue 2019-10-20 21:42:18 -04:00
Hykilpikonna 33ceaa38c0 [O] Use Navigation.updateIndex instead 2019-10-20 21:39:08 -04:00
Hykilpikonna 0a0288c2ee [+] Make updateIndex public 2019-10-20 21:38:20 -04:00
Hykilpikonna 90f888bc4b [+] Add instance to navigation 2019-10-20 21:38:11 -04:00
Hykilpikonna 9bb34fb2a4 [O] Make course operations unselectable 2019-10-20 21:34:13 -04:00
Hykilpikonna 22b75a6b30 [+] Add .unselectable to global css 2019-10-20 21:33:43 -04:00
Hykilpikonna 6af8410698 [F] Fix logic mistake 2019-10-20 21:32:30 -04:00
Hykilpikonna f023c724fa [O] Don't update history for initial update 2019-10-20 21:31:22 -04:00
Hykilpikonna 6bbbe9cece [O] Encapsulate update history in updateIndex() 2019-10-20 21:31:05 -04:00
Hykilpikonna e6a4a04bb4 [+] Only show next course when next course isn't null 2019-10-20 21:27:42 -04:00
Hykilpikonna 5c4a391d96 [O] Add jsdocs for findNextCourse 2019-10-20 21:23:53 -04:00
Hykilpikonna a75b15d840 [O] Separate findNextCourse() and nextCourse() 2019-10-20 21:23:29 -04:00
Hykilpikonna 1322bd6326 [O] Adjust opacity 2019-10-20 21:21:47 -04:00
Hykilpikonna e2997c345c [F] Fix null case 2019-10-20 21:20:39 -04:00
Hykilpikonna 923a7e824f [O] Add drop shadows 2019-10-20 21:19:18 -04:00
Hykilpikonna 10ac0b5330 [O] Separate padding from common css 2019-10-20 21:16:10 -04:00
Hykilpikonna bfeba9da40 [O] Put prev-course under navbar 2019-10-20 21:15:56 -04:00
Hykilpikonna 752a865334 [O] Align prev-course upward 2019-10-20 21:14:36 -04:00
Hykilpikonna 5eda771070 [M] Move common css properties to common class 2019-10-20 21:13:51 -04:00
Hykilpikonna 0826080f82 [O] Add css class to both course operations 2019-10-20 21:13:15 -04:00
Hykilpikonna 6fab785a49 [+] Add previous course div 2019-10-20 21:11:03 -04:00
Hykilpikonna ecbcca5f14 [+] Add index offset to nextCourse() 2019-10-20 21:10:53 -04:00
Hykilpikonna 861de56f10 [O] Make cursor a pointer 2019-10-20 21:02:39 -04:00
Hykilpikonna 3ce66e1201 [+] Implement next course 2019-10-20 21:01:53 -04:00
Hykilpikonna 7e8ea73363 [O] Make it a trapezoid with rotateX 2019-10-20 20:56:51 -04:00
Hykilpikonna 9142525d21 [O] Adjust width 2019-10-20 20:56:13 -04:00
Hykilpikonna 62577ff1bb [O] Add padding 2019-10-20 20:56:06 -04:00
Hykilpikonna 953556ccee [O] Reduce font size 2019-10-20 20:51:47 -04:00
Hykilpikonna cc8621f304 [O] Add background 2019-10-20 20:51:41 -04:00
Hykilpikonna baae26d244 [O] Bottom align and center 2019-10-20 20:51:32 -04:00
Hykilpikonna cbf70cbeef [+] Create next course div in navbar 2019-10-20 20:48:18 -04:00
7 changed files with 159 additions and 18 deletions
+11
View File
@@ -71,3 +71,14 @@ div.el-card.course-card > div.el-card__body
text-decoration: underline;
cursor: pointer;
}
// Non-selectable text
.unselectable
{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
+42 -1
View File
@@ -46,5 +46,46 @@
// Font
font-size: 1.25rem;
display: inline-flex;
}
#next-course
{
// Down center
width: 50%;
position: absolute;
bottom: 0;
left: 25%;
padding-top: 2px;
box-shadow: 0 -2px 9px 0 #ecebeb;
// Trapezoid
transform: perspective(50px) rotateX(10deg);
}
#prev-course
{
// Up center
width: 50%;
position: absolute;
top: 61px;
left: 25%;
padding-bottom: 2px;
box-shadow: 0 2px 9px 0 #ecebeb;
// Trapezoid
transform: perspective(50px) rotateX(-10deg);
}
.nav-course-operations
{
// Background
background-color: rgba(214, 214, 214, 0.67);
opacity: 0.85;
// Font
font-size: 14px;
color: #ab8585;
// Cursor
cursor: pointer;
}
+83 -13
View File
@@ -2,6 +2,7 @@ import {Component, Prop, Vue} from 'vue-property-decorator';
import Constants from '@/constants';
import {Course} from '@/components/app/app';
import {CourseUtils} from '@/utils/course-utils';
import {FormatUtils} from '@/utils/format-utils';
/**
* This component is the top navigation bar
@@ -14,20 +15,27 @@ export default class Navigation extends Vue
// @ts-ignore
@Prop() activeIndex: string;
@Prop() courses: any;
// @ts-ignore
@Prop() courses: Course[];
// Instance
public static instance: Navigation;
/**
* This is called when the instance is created.
*/
public created()
{
// Set instance
Navigation.instance = this;
// Set history state
let url = window.location.pathname;
if (url == '/' || url == '') url = '/overall';
window.history.replaceState({lastTab: url.substring(1)}, '', url);
// Update initial index
this.updateIndex(url.substring(1));
this.updateIndex(url.substring(1), false);
// Create history state listener
window.onpopstate = e =>
@@ -36,7 +44,7 @@ export default class Navigation extends Vue
{
// Restore previous tab
console.log(`onPopState: Current: ${this.activeIndex}, Previous: ${e.state.lastTab}`);
this.updateIndex(e.state.lastTab);
this.updateIndex(e.state.lastTab, false);
}
};
}
@@ -56,25 +64,87 @@ export default class Navigation extends Vue
{
// Update active index
this.updateIndex(index);
// Debug output TODO: Remove this
console.log(`onNavigate: Previous: ${this.activeIndex}, New: ${index}`);
// Check url
let url = `/${index}`;
// Push history state
window.history.pushState({lastTab: index}, '', url);
}
/**
* Update index
*
* @param newIndex New index
* @param history Record in history or not (Default true)
*/
private updateIndex(newIndex: string)
public updateIndex(newIndex: string, history?: boolean)
{
// Call custom event
this.$emit('update:activeIndex', newIndex);
// Record or not
if (history == null || history)
{
// Debug output TODO: Remove this
console.log(`onNavigate: Previous: ${this.activeIndex}, New: ${newIndex}`);
// Check url
let url = `/${newIndex}`;
// Push history state
window.history.pushState({lastTab: newIndex}, '', url);
}
// Update title
document.title = 'Veracross Analyzer - ' + this.getTitle(newIndex);
}
/**
* Get title for index
*
* @param index Index
*/
public getTitle(index: string)
{
// Course
if (index.startsWith('course'))
{
return this.findCourse(index.split('/')[1], 0).name;
}
// Others
return FormatUtils.toTitleCase(index);
}
/**
* Move to the next course
*
* @param indexOffset Index offset (Eg. 1 for next)
*/
public nextCourse(indexOffset: number)
{
// Set tab to the next index
this.updateIndex(CourseUtils.formatTabIndex(this.findNextCourse(indexOffset)))
}
/**
* Find the next course
*
* @param indexOffset Index offset (Eg. 1 for next)
*/
public findNextCourse(indexOffset: number)
{
return this.findCourse(this.activeIndex.split('/')[1], indexOffset);
}
/**
* Find course
*
* @param courseId Course ID
* @param indexOffset Index offset (Eg. 1 for next)
*/
public findCourse(courseId: string, indexOffset: number)
{
// Find current course index
let courseIndex = this.courses.findIndex(c => c.id == +courseId);
// Find next course
return this.courses[courseIndex + indexOffset];
}
/**
+8 -1
View File
@@ -18,7 +18,14 @@
<el-button @click="signOut" id="sign-out-button" type="text">Sign Out</el-button>
</el-menu>
<div class="line"></div>
<div v-if="activeIndex.includes('course') && findNextCourse(-1) != null"
@click="nextCourse(-1)" id="prev-course" class="nav-course-operations unselectable">
PREVIOUS COURSE
</div>
<div v-if="activeIndex.includes('course') && findNextCourse(1) != null"
@click="nextCourse(1)" id="next-course" class="nav-course-operations unselectable">
NEXT COURSE
</div>
</div>
</template>
+1 -1
View File
@@ -7,7 +7,7 @@ export default class Constants
public static API_URL: string = 'https://va.hydev.org/api';
/** Current version */
public static VERSION: string = '0.3.5.703';
public static VERSION: string = '0.3.6.741';
/** Minimum version that still supports the same cookies */
public static MIN_SUPPORTED_VERSION: string = '0.3.4.561';
@@ -27,6 +27,7 @@
import {Component, Prop, Vue} from 'vue-property-decorator';
import App, {Course} from '@/components/app/app';
import {CourseUtils} from '@/utils/course-utils';
import Navigation from '@/components/navigation/navigation';
@Component({
components: {}
@@ -48,7 +49,7 @@
redirect()
{
if (!this.clickable) return;
App.instance.selectedTab = CourseUtils.formatTabIndex(this.course);
Navigation.instance.updateIndex(CourseUtils.formatTabIndex(this.course));
}
}
</script>
+12 -1
View File
@@ -22,8 +22,19 @@ export class FormatUtils
* @param str String
* @param length Max length
*/
static limit(str: string, length: number): string
public static limit(str: string, length: number): string
{
return str.length <= length ? str : str.substr(0, length - 2) + '...'
}
/**
* To Title Case
*
* @param str oRigInAL sTrING
* @return string Original String
*/
public static toTitleCase(str: string)
{
return str.replace(/\w\S*/g, s => s.charAt(0).toUpperCase() + s.substr(1).toLowerCase())
}
}