-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathui.js
82 lines (68 loc) · 2.19 KB
/
ui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"use strict";
// app ui - Boot stuff when DOM is loaded
$(function () {
console.group('UI');
console.log('DOM Loaded.');
console.log('Based on Fomantic-UI.');
console.log('Loaded modules:', (typeof $.site.settings !== undefined ? $.site.settings.modules : null));
console.log('Available hooks:', (typeof window.UI !== undefined ? window.UI : null));
console.groupEnd();
// Disabled links
$('a[href="#!"]').on('click', function(event) {
event.preventDefault();
});
// Fix top menu when passed
$('.ui.large.secondary.inverted.menu').visibility({
once: false,
onBottomPassed: function() {
$('.fixed.menu').transition('fade in');
},
onBottomPassedReverse: function() {
$('.fixed.menu').transition('fade out');
}
});
// Create sidebar and attach to menu open
$('.ui.sidebar')
// .sidebar('setting', { transition: 'scale down', mobileTransition: 'scale down' })
.sidebar('setting', { transition: 'overlay', mobileTransition: 'overlay' })
.sidebar('attach events', '.toc.item');
// Dropdowns
$('.ui.dropdown').dropdown({
on: 'hover'
});
// Accordions
$('.ui.accordion').accordion();
// Checkboxes
$('.ui.checkbox').checkbox()
// Dismissable messages
$('.message .close').on('click', function() {
$(this).closest('.message').transition('fade');
});
// Modals
$('.ui.modal').modal();
// Tooltips
$('.tooltipped').popup();
// Scrolling tables
// TODO: Add throttling...
$('.scrolling-table').on('scroll', function (event) {
// console.log('User is scrolling the table content.', event);
// console.info('Scroll position:', event.target.scrollTop);
// console.info('This:', $(this));
// console.info('Table header:', $(this).find('.ui.table.sticky-headed thead tr:first-child > th'));
// Store scroll position
var pos = event.target.scrollTop;
// Target next table with sticky headers
var $tableHeaders = $(this).find('.ui.table.sticky-headed thead tr:first-child > th');
// Set a darker background color when user is scrolling table content
if (pos !== 0) {
if (!$tableHeaders.hasClass('darken')) {
$tableHeaders.addClass('darken');
}
}
else {
if ($tableHeaders.hasClass('darken')) {
$tableHeaders.removeClass('darken');
}
}
});
});