You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ni...@apache.org on 2016/01/20 01:55:16 UTC
docs commit: CB-10367 Add meaningful names to heading anchors in Docs
& show a link icon on hover. This closes #457
Repository: cordova-docs
Updated Branches:
refs/heads/master b2eaae225 -> d9f188650
CB-10367 Add meaningful names to heading anchors in Docs & show a link icon on hover. This closes #457
Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/d9f18865
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/d9f18865
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/d9f18865
Branch: refs/heads/master
Commit: d9f18865066cc751a3242b44532391b84f2df8d5
Parents: b2eaae2
Author: Nikhil Khandelwal <ni...@microsoft.com>
Authored: Fri Jan 15 13:46:12 2016 -0800
Committer: Nikhil Khandelwal <ni...@microsoft.com>
Committed: Tue Jan 19 16:53:44 2016 -0800
----------------------------------------------------------------------
_config.yml | 3 +++
www/static/css-src/main.scss | 21 +++++++++++++++++++++
www/static/js/docs.js | 22 +++++++++++++++++-----
3 files changed, 41 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d9f18865/_config.yml
----------------------------------------------------------------------
diff --git a/_config.yml b/_config.yml
index 91b1e9d..c0abd29 100644
--- a/_config.yml
+++ b/_config.yml
@@ -73,6 +73,9 @@ redcarpet:
- lax_spacing
- tables
+
+ # enables anchor links
+ - with_toc_data
kramdown:
input: GFM
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d9f18865/www/static/css-src/main.scss
----------------------------------------------------------------------
diff --git a/www/static/css-src/main.scss b/www/static/css-src/main.scss
index d0f718a..dbde344 100644
--- a/www/static/css-src/main.scss
+++ b/www/static/css-src/main.scss
@@ -111,6 +111,27 @@ footer .copyright_text {
}
/*
+* Anchor links on documentation headers
+*/
+.header-link {
+ position: relative;
+ left: 0.5em;
+ opacity: 0;
+
+ -webkit-transition: opacity 0.2s ease-in-out 0.1s;
+ -moz-transition: opacity 0.2s ease-in-out 0.1s;
+ -ms-transition: opacity 0.2s ease-in-out 0.1s;
+}
+
+h2:hover .header-link,
+h3:hover .header-link,
+h4:hover .header-link,
+h5:hover .header-link,
+h6:hover .header-link {
+ opacity: 1;
+}
+
+/*
********* Modifications to Bootstrap ***********
*/
button.btn, a.btn {
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/d9f18865/www/static/js/docs.js
----------------------------------------------------------------------
diff --git a/www/static/js/docs.js b/www/static/js/docs.js
index 214336f..6ec407b 100644
--- a/www/static/js/docs.js
+++ b/www/static/js/docs.js
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
$(document).ready(function () {
@@ -28,6 +29,14 @@ $(document).ready(function () {
}
return name;
}
+
+ var anchorLink = function (id) {
+ var anchor = document.createElement("a");
+ anchor.className = "header-link";
+ anchor.href = "#" + id;
+ anchor.innerHTML = "<i class=\"glyphicon glyphicon-link\"></i>";
+ return anchor;
+ }
// Table of Contents
$('#page-toc').toc({
@@ -44,11 +53,14 @@ $(document).ready(function () {
return $heading.text();
},
'itemClass': function(i, heading, $heading, prefix) { // custom function for item class
-
- // add a special class to the anchor for this toc entry
- var anchorName = getAnchorName(i, heading, prefix);
- $('#' + anchorName).addClass('fragment-anchor');
-
+ // the first link is the H1 header of the page - exclude it
+ if (i > 0) {
+ // add a special class to the anchor for this toc entry
+ var anchorName = getAnchorName(i, heading, prefix);
+ $('#' + anchorName).addClass('fragment-anchor');
+
+ $heading.append(anchorLink(anchorName));
+ }
// don't assign any special classes to the toc entry itself
return '';
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org