aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'view/js/main.js')
-rw-r--r--view/js/main.js67
1 files changed, 51 insertions, 16 deletions
diff --git a/view/js/main.js b/view/js/main.js
index 96adf0be3..2fc912093 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -434,26 +434,36 @@ function contextualHelp() {
if(container.hasClass('contextual-help-content-open')) {
container.removeClass('contextual-help-content-open');
- $('main').css('top', '')
+ $('main').css('margin-top', '')
}
else {
container.addClass('contextual-help-content-open');
var mainTop = container.outerHeight(true);
- $('main').css('top', mainTop + 'px');
+ $('main').css('margin-top', mainTop + 'px');
}
}
function contextualHelpFocus(target, openSidePanel) {
- if (openSidePanel) {
- $("main").addClass('region_1-on'); // Open the side panel to highlight element
- }
- else {
- $("main").removeClass('region_1-on');
- }
- $('html,body').animate({ scrollTop: $(target).offset().top - $('nav').outerHeight(true) - $('#contextual-help-content').outerHeight(true)}, 'slow');
- for (i = 0; i < 3; i++) {
- $(target).fadeTo('slow', 0.1).fadeTo('slow', 1.0);
- }
+ if($(target).length) {
+ if (openSidePanel) {
+ $("main").addClass('region_1-on'); // Open the side panel to highlight element
+ }
+ else {
+ $("main").removeClass('region_1-on');
+ }
+
+ var css_position = $(target).parent().css('position');
+ if (css_position === 'fixed') {
+ $(target).parent().css('position', 'static');
+ }
+
+ $('html,body').animate({ scrollTop: $(target).offset().top - $('nav').outerHeight(true) - $('#contextual-help-content').outerHeight(true)}, 'slow');
+ for (i = 0; i < 3; i++) {
+ $(target).fadeTo('slow', 0.1).fadeTo('slow', 1.0);
+ }
+
+ $(target).parent().css('position', css_position);
+ }
}
function updatePageItems(mode, data) {
@@ -652,7 +662,13 @@ function updateConvItems(mode,data) {
}
// auto-scroll to a particular comment in a thread (designated by mid) when in single-thread mode
- if($('.item_' + bParam_mid.substring(0,32)).length && !$('.item_' + bParam_mid.substring(0,32)).hasClass('toplevel_item') && mode == 'replace') {
+ // use the same method to generate the submid as we use in ThreadItem,
+ // substr(0,32) + base64_encode + replace(['+','='],['','']);
+ var submid = bParam_mid;
+ var submid_encoded = ((submid.length) ? submid.substring(0,32) : 'abcdefg');
+ submid_encoded = window.btoa(submid_encoded);
+ submid_encoded = submid_encoded.replace(/[\+\=]/g,'');
+ if($('.item_' + submid_encoded).length && !$('.item_' + submid_encoded).hasClass('toplevel_item') && mode == 'replace') {
if($('.collapsed-comments').length) {
var scrolltoid = $('.collapsed-comments').attr('id').substring(19);
$('#collapsed-comments-' + scrolltoid + ' .autotime').timeago();
@@ -660,10 +676,12 @@ function updateConvItems(mode,data) {
$('#hide-comments-' + scrolltoid).html(aStr.showfewer);
$('#hide-comments-total-' + scrolltoid).hide();
}
- $('html, body').animate({ scrollTop: $('.item_' + bParam_mid.substring(0,32)).offset().top - $('nav').outerHeight() }, 'slow');
- $('.item_' + bParam_mid.substring(0,32)).addClass('item-highlight');
+ $('html, body').animate({ scrollTop: $('.item_' + submid_encoded).offset().top - $('nav').outerHeight() }, 'slow');
+ $('.item_' + submid_encoded).addClass('item-highlight');
}
+ $(document.body).trigger("sticky_kit:recalc");
+
}
function collapseHeight() {
@@ -1144,6 +1162,24 @@ function preview_post() {
return true;
}
+function preview_mail() {
+ $("#mail-preview").val("1");
+ $("#mail-preview-content").show();
+ $.post(
+ "mail",
+ $("#prvmail-form").serialize(),
+ function(data) {
+ if(data.preview) {
+ $("#mail-preview-content").html(data.preview);
+ $("#mail-preview-content" + " a").click(function() { return false; });
+ }
+ },
+ "json"
+ );
+ $("#mail-preview").val("0");
+ return true;
+}
+
function unpause() {
// unpause auto reloads if they are currently stopped
totStopped = false;
@@ -1313,7 +1349,6 @@ $(document).ready(function() {
numbers : aStr['t17'],
};
- $("#toc").toc();
});
function zFormError(elm,x) {