qt5base-lts/doc/global/qt-html-templates-offline-simple.qdocconf
Eike Ziller 3b962d16db Fix jumping to anchors with offline style
If the style changes after the browser already jumped to an anchor,
the resulting browser position will be messed up.
So, after we changed the style we need to make sure that we jump
to the anchor again.
Since browsers do not jump to anchors that they already jumped to,
that means first jumping to the top, then to the actual anchor.

Task-number: QTCREATORBUG-18448
Change-Id: I86c736adab6940903276f8a896b4054ddae11ebe
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2017-08-29 11:25:27 +00:00

46 lines
1.6 KiB
Plaintext

# Specify a custom CSS file used by this template
HTML.stylesheets += template/style/offline-simple.css
qhp.extraFiles += style/offline-simple.css
# Override the header styles
HTML.headerstyles = \
" <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline-simple.css\" />\n" \
" <script type=\"text/javascript\">\n" \
" document.getElementsByTagName(\"link\").item(0).setAttribute(\"href\", \"style/offline.css\");\n" \
" // loading style sheet breaks anchors that were jumped to before\n" \
" // so force jumping to anchor again\n" \
" setTimeout(function() {\n" \
" var anchor = location.hash;\n" \
" // need to jump to different anchor first (e.g. none)\n" \
" location.hash = \"#\";\n" \
" setTimeout(function() {\n" \
" location.hash = anchor;\n" \
" }, 0);\n" \
" }, 0);\n" \
" </script>\n"
HTML.postheader = \
"<body>\n" \
"<div class=\"header\" id=\"qtdocheader\">\n"\
" <div class=\"main\">\n" \
" <div class=\"main-rounded\">\n" \
" <div class=\"navigationbar\">\n" \
" <table><tr>\n"
HTML.postpostheader = \
" </tr></table>\n"\
" </div>\n" \
" </div>\n" \
"<div class=\"content\">\n" \
"<div class=\"line\">\n" \
"<div class=\"content mainContent\">\n"
HTML.navigationseparator = \
"<span class=\"naviSeparator\"> &#9702; </span>\n"
# Add some padding around code snippets, as we cannot
# currectly style them for QTextBrowser using only CSS.
codeindent = 2
codeprefix = "\n\n"
codesuffix = "\n\n"