|
@@ -55,39 +55,6 @@ Crowi.userPicture = function(user) {
|
|
|
return user.image || '/images/icons/user.svg';
|
|
return user.image || '/images/icons/user.svg';
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-Crowi.modifyScrollTop = function() {
|
|
|
|
|
- const offset = 10;
|
|
|
|
|
-
|
|
|
|
|
- const hash = window.location.hash;
|
|
|
|
|
- if (hash === '') {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const pageHeader = document.querySelector('#page-header');
|
|
|
|
|
- if (!pageHeader) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- const pageHeaderRect = pageHeader.getBoundingClientRect();
|
|
|
|
|
-
|
|
|
|
|
- const sectionHeader = Crowi.findSectionHeader(hash);
|
|
|
|
|
- if (sectionHeader === null) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- let timeout = 0;
|
|
|
|
|
- if (window.scrollY === 0) {
|
|
|
|
|
- timeout = 200;
|
|
|
|
|
- }
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- const sectionHeaderRect = sectionHeader.getBoundingClientRect();
|
|
|
|
|
- if (sectionHeaderRect.top >= pageHeaderRect.bottom) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- window.scrollTo(0, (window.scrollY - pageHeaderRect.height - offset));
|
|
|
|
|
- }, timeout);
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
Crowi.initClassesByOS = function() {
|
|
Crowi.initClassesByOS = function() {
|
|
|
// add classes to cmd-key by OS
|
|
// add classes to cmd-key by OS
|
|
|
const platform = navigator.platform.toLowerCase();
|
|
const platform = navigator.platform.toLowerCase();
|
|
@@ -112,63 +79,6 @@ Crowi.initClassesByOS = function() {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-window.addEventListener('load', () => {
|
|
|
|
|
- const crowi = window.crowi;
|
|
|
|
|
- if (crowi && crowi.users && crowi.users.length !== 0) {
|
|
|
|
|
- const totalUsers = crowi.users.length;
|
|
|
|
|
- const $listLiker = $('.page-list-liker');
|
|
|
|
|
- $listLiker.each((i, liker) => {
|
|
|
|
|
- const count = $(liker).data('count') || 0;
|
|
|
|
|
- if (count / totalUsers > 0.05) {
|
|
|
|
|
- $(liker).addClass('popular-page-high');
|
|
|
|
|
- // 5%
|
|
|
|
|
- }
|
|
|
|
|
- else if (count / totalUsers > 0.02) {
|
|
|
|
|
- $(liker).addClass('popular-page-mid');
|
|
|
|
|
- // 2%
|
|
|
|
|
- }
|
|
|
|
|
- else if (count / totalUsers > 0.005) {
|
|
|
|
|
- $(liker).addClass('popular-page-low');
|
|
|
|
|
- // 0.5%
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- const $listSeer = $('.page-list-seer');
|
|
|
|
|
- $listSeer.each((i, seer) => {
|
|
|
|
|
- const count = $(seer).data('count') || 0;
|
|
|
|
|
- if (count / totalUsers > 0.10) {
|
|
|
|
|
- // 10%
|
|
|
|
|
- $(seer).addClass('popular-page-high');
|
|
|
|
|
- }
|
|
|
|
|
- else if (count / totalUsers > 0.05) {
|
|
|
|
|
- // 5%
|
|
|
|
|
- $(seer).addClass('popular-page-mid');
|
|
|
|
|
- }
|
|
|
|
|
- else if (count / totalUsers > 0.02) {
|
|
|
|
|
- // 2%
|
|
|
|
|
- $(seer).addClass('popular-page-low');
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- blinkSectionHeaderAtBoot();
|
|
|
|
|
-
|
|
|
|
|
- Crowi.modifyScrollTop();
|
|
|
|
|
- Crowi.initClassesByOS();
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-window.addEventListener('hashchange', (e) => {
|
|
|
|
|
- Crowi.modifyScrollTop();
|
|
|
|
|
-
|
|
|
|
|
- // hash on page
|
|
|
|
|
- if (window.location.hash) {
|
|
|
|
|
- if (window.location.hash === '#edit') {
|
|
|
|
|
- Crowi.setCaretLineAndFocusToEditor();
|
|
|
|
|
- }
|
|
|
|
|
- // else if (window.location.hash === '#hackmd') {
|
|
|
|
|
- // }
|
|
|
|
|
- }
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
// adjust min-height of page for print temporarily
|
|
// adjust min-height of page for print temporarily
|
|
|
window.onbeforeprint = function() {
|
|
window.onbeforeprint = function() {
|
|
|
$('#page-wrapper').css('min-height', '0px');
|
|
$('#page-wrapper').css('min-height', '0px');
|