Newer Older
106 lines | 3.376kb
add files
Yuki Kimoto authored on 2014-03-26
1
%= javascript '/mojo/jquery/jquery.js'
2
<div id="mojobar">
3
  %= stylesheet scoped => 'scoped', begin
4
    #mojobar {
5
      background-color: #1a1a1a;
6
      background: -webkit-linear-gradient(top, #2a2a2a 0%, #000 100%);
7
      background: -moz-linear-gradient(top, #2a2a2a 0%, #000 100%);
8
      background: linear-gradient(top, #2a2a2a 0%, #000 100%);
9
      box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.6);
10
      height: 46px;
11
      overflow: hidden;
12
      position: absolute;
13
      text-align: right;
14
      vertical-align: middle;
15
      width: 100%;
16
      z-index: 1000;
17
    }
18
    #mojobar-logo {
19
      float: left;
20
      margin-left: 5em;
21
      padding-top: 3px;
22
    }
23
    #mojobar-links {
24
      display:table-cell;
25
      float: right;
26
      height: 60px;
27
      margin-right: 5em;
28
      margin-top: 0.8em;
29
    }
30
    #mojobar-links a {
31
      color: #ccc;
32
      font: 1em 'Helvetica Neue', Helvetica, sans-serif;
33
      font-weight: 300;
34
      margin-left: 0.5em;
35
      text-decoration: none;
36
      transition: all 200ms ease-in-out;
37
    }
38
    #mojobar-links a:hover { color: #fff }
39
    #mojobar-links input {
40
      border: 0;
41
      border-radius: 10px;
42
      display: inline;
43
      margin-left: 1em;
44
      padding: 3px;
45
    }
46
    #mojobar-links input:focus { outline: 0 }
47
    #mojobar-links form { display: inline }
48
  % end
49
  <div id="mojobar-logo">
50
    %= link_to 'http://mojolicio.us' => begin
51
      %= image '/mojo/logo-white.png', alt => 'Mojolicious logo'
52
    % end
53
  </div>
54
  <div id="mojobar-links">
55
    %= link_to Documentation => 'http://mojolicio.us/perldoc'
56
    %= link_to Wiki => 'https://github.com/kraih/mojo/wiki'
57
    %= link_to GitHub => 'https://github.com/kraih/mojo'
58
    %= link_to CPAN => 'http://metacpan.org/release/Mojolicious/'
59
    %= link_to MailingList => 'http://groups.google.com/group/mojolicious'
60
    %= link_to Blog => 'http://blog.kraih.com'
61
    %= link_to Twitter => 'http://twitter.com/kraih'
62
    %= form_for 'http://google.com/cse' => (target => '_blank') => begin
63
      %= hidden_field cx => '014527573091551588235:pwfplkjpgbi'
64
      %= hidden_field ie => 'UTF-8'
65
      %= search_field 'q', placeholder => 'Search'
66
    %= end
67
  </div>
68
</div>
69
%= javascript begin
70
  $(window).load(function () {
71
    if (window.location.hash) {
72
      var tweak = $(window.location.hash).offset().top - 50;
73
      $('html, body').animate({scrollTop:tweak}, 1);
74
    }
75
    var mojobar = $('#mojobar');
76
    var start   = mojobar.offset().top;
77
    var fixed;
78
    $(window).scroll(function () {
79
      if (!fixed && (mojobar.offset().top - $(window).scrollTop() < 0)) {
80
        mojobar.css('top', 0);
81
        mojobar.css('position', 'fixed');
82
        fixed = true;
83
      } else if (fixed && $(window).scrollTop() <= start) {
84
        mojobar.css('position', 'absolute');
85
        mojobar.css('top', start + 'px');
86
        fixed = false;
87
      }
88
    });
89
  });
90
  $(document).ready(function() {
91
    $('a[href^="#"]').addClass('mojoscroll');
92
    $(".mojoscroll").click(function(e) {
93
      e.preventDefault();
94
      e.stopPropagation();
95
      var parts  = this.href.split("#");
96
      var hash   = "#" + parts[1];
97
      var target = $(hash);
98
      var top    = target.offset().top - 50;
99
      var old    = target.attr('id');
100
      target.attr('id', '');
101
      location.hash = hash;
102
      target.attr('id', old);
103
      $('html, body').animate({scrollTop:top}, 1);
104
    });
105
  });
106
% end