Skip to content
Browse files

added (tentative) sausage.js integration--probably needs more testing...

  • Loading branch information...
1 parent 1166de7 commit 438d7d9f202fbc6b65ba497e0fde302c27308a13 @christophercliff christophercliff committed
Showing with 112 additions and 1 deletion.
  1. +61 −1 script.js
  2. +1 −0 style.css
  3. +3 −0 style/all/base.css
  4. +47 −0 style/all/sausage.css
View
62 script.js
@@ -78,7 +78,9 @@ var l10n = {
};
var scripts = [
- "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js",
+ "http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js",
+ "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js",
+ "https://github.com/christophercliff/sausage/raw/master/jquery.sausage.js",
"http://www.google-analytics.com/ga.js"
];
@@ -313,6 +315,62 @@ function autolink() {
});
}
+function chop() {
+
+ var $content = $(".content"),
+ $sections = $("<div/>"),
+ $as = $content.find("a.anchor"),
+ j = -1;
+
+ $as
+ .each(function(i, el){
+
+ $sections
+ .append("<section/>")
+ ;
+
+ })
+ ;
+
+ $content.children()
+ .each(function(i, el){
+
+ var $el = $(el),
+ $section;
+
+ if ($el.hasClass("anchor"))
+ {
+ j++;
+ }
+
+ $section = $sections.find("section").eq(j) || $sections;
+
+ $section
+ .append($(el).clone())
+ ;
+
+ })
+ ;
+
+ $content
+ .html($sections)
+ ;
+
+}
+
+function sausage() {
+ $(window)
+ .sausage({
+ page: "section",
+ content: function (i, $page) {
+ return "<span class='sausage-span'>"
+ + $page.find(".anchor").first().text()
+ + "</span>";
+ }
+ })
+ ;
+}
+
function get_lang() {
var matches = document.location.href.match(urls[0][0]);
if (matches && matches.length > 2) {
@@ -341,6 +399,8 @@ document.onready = function() {
template();
build();
autolink();
+ chop();
+ sausage();
track();
} catch (error) {
// uh oh
View
1 style.css
@@ -1,3 +1,4 @@
@import url("style/all/base.css");
+@import url("style/all/sausage.css");
@import url("style/print/base.css") print;
View
3 style/all/base.css
@@ -262,6 +262,9 @@ container: 12*60px (unit) + 13*16px (gutter) = 928px = 58em = 100%
float: left;
margin-right: 2.6%;
}
+.content section {
+ margin-bottom: 3em;
+}
/* sidebar */
.sidebar {
View
47 style/all/sausage.css
@@ -0,0 +1,47 @@
+.sausage-set {
+ position: fixed; right: 0; top: 0;
+ width: 15px; height: 100%;
+ border-left: solid 2px #fff;
+ border-right: solid 2px #fff;
+ background-color: #fff;
+}
+ .sausage {
+ position: absolute; left: 0;
+ width: 100%; height: 100%;
+ background-color: #f1f1f1;
+ text-decoration: none;
+ -moz-border-radius: 8px;
+ -webkit-border-bottom-left-radius: 8px;
+ -webkit-border-top-left-radius: 8px;
+ -webkit-border-bottom-right-radius: 8px;
+ -webkit-border-top-right-radius: 8px;
+ -moz-box-shadow: inset 0px 1px 2px 4px rgba(0, 0, 0, 0.025);
+ -webkit-box-shadow: inset 0px 1px 2px 4px rgba(0, 0, 0, 0.025);
+ cursor: pointer;
+ }
+ .sausage-hover,
+ .sausage-current {
+ background-color: #f2e4ed;
+ -moz-box-shadow: inset 0px 1px 2px 4px rgba(51, 63, 70, 0.025);
+ }
+ .sausage-span {
+ position: absolute; right: 24px; top: 5px; z-index: 2;
+ display: none;
+ width: 100px;
+ padding: 2px 3px;
+ color: #000;
+ background-color: #fff;
+ border: solid 2px #990066;
+ font-size: 10px; line-height: 12px; font-weight: bold; text-align: center;
+ -moz-border-radius: 7px;
+ -webkit-border-bottom-left-radius: 7px;
+ -webkit-border-top-left-radius: 7px;
+ -webkit-border-bottom-right-radius: 7px;
+ -webkit-border-top-right-radius: 7px;
+ -moz-box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.05);
+ -webkit-box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.05);
+ }
+ .sausage-hover .sausage-span,
+ .sausage-current .sausage-span {
+ display: block;
+ }

0 comments on commit 438d7d9

Please sign in to comment.
Something went wrong with that request. Please try again.