Permalink
Browse files

Anchor smooth scrolling, github badge

  • Loading branch information...
1 parent a880da8 commit 9e7c9854b4cb0bb9966959c5ce6ad52f0a16b22e @winton committed Jul 6, 2011
Showing with 34 additions and 63 deletions.
  1. +4 −8 README.md
  2. BIN site/github.png
  3. +5 −1 site/index.html.haml
  4. +14 −0 site/stasis.css.scss
  5. +11 −54 site/stasis.js.coffee
View
12 README.md
@@ -3,10 +3,6 @@ Stasis
Stasis is a dynamic framework for static sites.
-When coupled with [metastasis](https://github.com/winton/metastasis), Stasis can even respond to dynamic user input.
-
-The end goal? Making a high-performance web framework that serves pages solely through Nginx.
-
Install
-------
@@ -70,7 +66,7 @@ Example directory structure:
Before
------
-Use `before` blocks within your `controller.rb` to execute code before templates render.
+Use `before` blocks within `controller.rb` to execute code before templates render.
`controller.rb`:
@@ -94,7 +90,7 @@ Layouts
%html
%body= yield
-In your `controller.rb`, set the default layout:
+In `controller.rb`, set the default layout:
layout 'layout.html.haml'
@@ -163,7 +159,7 @@ The `say_hello` method is now available to all `before` blocks and templates.
Ignore
------
-Use the `ignore` method in your `controller.rb` to ignore certain paths.
+Use the `ignore` method in `controller.rb` to ignore certain paths.
Ignore filenames with an underscore at the beginning:
@@ -172,7 +168,7 @@ Ignore filenames with an underscore at the beginning:
Priority
--------
-Use the `priority` method in your `controller.rb` to change the file process order.
+Use the `priority` method in `controller.rb` to change the file process order.
Copy `.txt` files before rendering `index.html.erb`:
View
BIN site/github.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 site/index.html.haml
@@ -9,6 +9,9 @@
- @links.each do |link|
%li
%a{ :href => "##{link[:href]}" }= link[:name]
+ #github
+ %a{ :href => 'https://github.com/winton/stasis' }
+ %img{ :src => 'github.png', :width => 141, :height => 141 }>
#title
%img{ :src => 'stasis.png' }>
stasis
@@ -17,4 +20,5 @@
#body
~ @readme
.clear
- %script{ :src => "jquery-1.6.2.js", :type => "text/javascript" }
+ %script{ :src => "jquery-1.6.2.js", :type => "text/javascript" }
+ %script{ :src => "stasis.js", :type => "text/javascript" }
View
14 site/stasis.css.scss
@@ -17,10 +17,15 @@ body {
margin: 0 0 50px;
}
+ul, #title, #tm {
+ min-width: 800px;
+}
+
ul {
background-color: #CCD7E1;
font-size: 14px;
font-weight: 600;
+ height: 25px;
margin: 0;
padding: 0;
position: fixed;
@@ -36,6 +41,15 @@ ul {
}
}
+#github {
+ position: fixed;
+ height: 141px;
+ right: 0;
+ top: 25px;
+ width: 141px;
+ z-index: 10000;
+}
+
#title {
color: #3393E4;
font-family: 'Amaranth', sans-serif;
View
65 site/stasis.js.coffee
@@ -1,54 +1,11 @@
-###
-$(document).ready(function() {
- function filterPath(string) {
- return string
- .replace(/^\//,'')
- .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
- .replace(/\/$/,'');
- }
- var locationPath = filterPath(location.pathname);
- var scrollElem = scrollableElement('html', 'body');
-
- $('a[href*=#]').each(function() {
- var thisPath = filterPath(this.pathname) || locationPath;
- if ( locationPath == thisPath
- && (location.hostname == this.hostname || !this.hostname)
- && this.hash.replace(/#/,'') ) {
- var $target = $(this.hash), target = this.hash;
- if (target) {
- var targetOffset = $target.offset().top;
- $(this).click(function(event) {
- event.preventDefault();
- $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
- location.hash = target;
- });
- });
- }
- }
- });
-
- // use the first element that is "scrollable"
- function scrollableElement(els) {
- for (var i = 0, argLength = arguments.length; i <argLength; i++) {
- var el = arguments[i],
- $scrollElement = $(el);
- if ($scrollElement.scrollTop()> 0) {
- return el;
- } else {
- $scrollElement.scrollTop(1);
- var isScrollable = $scrollElement.scrollTop()> 0;
- $scrollElement.scrollTop(0);
- if (isScrollable) {
- return el;
- }
- }
- }
- return [];
- }
-
-});
-###
-
-(x) ->
- alert 'test'
- alert 'test2'
+$('a[href*=#]').click ->
+ anchor = $(this).attr('href').match(/#(.*)/)[1]
+ target = $('a[name=' + anchor + ']')
+ ran = false
+ $('html, body').animate { scrollTop: target.offset().top - 60 }, 400, ->
+ unless ran
+ offset = this.scrollTop
+ location.hash = anchor
+ this.scrollTop = offset
+ ran = true
+ false

0 comments on commit 9e7c985

Please sign in to comment.