Skip to content

Commit c900703

Browse files
committed
Updated windowResize, page unload, page error and minor some tweaks for performance
1 parent db956cc commit c900703

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

public/js/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ $(document).ready(function () {
400400
clearMap();
401401
}
402402
checkEditorStyle();
403-
changeMode(currentMode);
404403
/* we need this only on touch devices */
405404
if (isTouchDevice) {
406405
/* cache dom references */
@@ -423,13 +422,18 @@ $(document).ready(function () {
423422
});
424423
//when page resize
425424
$(window).resize(function () {
425+
checkLayout();
426+
checkEditorStyle();
427+
checkTocStyle();
428+
checkCursorMenu();
429+
windowResize();
426430
});
427431
//when page unload
428432
$(window).unload(function () {
429-
writeHistory(ui.area.markdown);
433+
updateHistoryInner();
430434
});
431435
$(window).error(function () {
432-
setNeedRefresh();
436+
//setNeedRefresh();
433437
});
434438

435439
//when page hash change
@@ -460,9 +464,11 @@ var windowResizeDebounce = 200;
460464
var windowResize = _.debounce(windowResizeInner, windowResizeDebounce);
461465

462466
function windowResizeInner() {
467+
checkLayout();
463468
checkResponsive();
464469
checkEditorStyle();
465470
checkTocStyle();
471+
checkCursorMenu();
466472
//refresh editor
467473
if (loaded) {
468474
editor.setOption('viewportMargin', Infinity);
@@ -480,6 +486,11 @@ function windowResizeInner() {
480486
}
481487
}
482488

489+
function checkLayout() {
490+
var navbarHieght = $('.navbar').outerHeight();
491+
$('body').css('padding-top', navbarHieght + 'px');
492+
}
493+
483494
function editorHasFocus() {
484495
return $(editor.getInputField()).is(":focus");
485496
}

0 commit comments

Comments
 (0)