mixin labelForSymbolType(symbol)
  div(class=["label", "label-"+(symbol.gtype === "function" || symbol.gtype === "method" ? "info" : "success"), "mr5"])= symbol.ctx.type

mixin mainContent
  if locals.readme
    section(id=name) !{readme}
  each symbol in dox
    if symbol.ctx.name
      section(id=symbol.ctx.name)
          h1= symbol.ctx.name
          h5.subheader
          if !symbol.gtype && symbol.type
            p
              div(class=["label", "label-inverse", "radius", "ctx-type"])= symbol.type
          else
            p
              mixin labelForSymbolType(symbol)
              if symbol.ctx.string
                span= symbol.ctx.string
              if symbol.return
                |  ->
                span= symbol.return

    .description !{symbol.description.full} !{symbol.description.extra}
    if symbol.hasParams
      h5 参数说明
      table.table.table-bordered.table-striped
        thead
          tr
            th(style="width:15%") 名称
            th(style="width:15%") 类型
            th 描述
        tbody
          each tag in symbol.tags
            if tag.type == 'param'
              tr
                td= tag.name
                td= tag.types
                td!= tag.description
    if symbol.jsfiddle
      h5 jsFiddle
      p
        iframe(width="100%", height="300", src=symbol.jsfiddle , allowfullscreen="allowfullscreen", frameborder="0")

doctype html
html
  head
    meta(name="viewport", content="width=device-width, initial-scale=1.0", charset="utf-8")
    title= title
    link(rel="icon", type="image/x-icon", href="favicon.ico")
    link(rel="stylesheet", href="bower_components/bootstrap/dist/css/bootstrap.min.css")
    link(rel="stylesheet", href="bower_components/prism/themes/prism.css")
    link(rel="stylesheet", href="css/api.css")

  body
    header#header.navbar.navbar-inverse.navbar-fixed-top.bs-docs-nav
      .container
        .navbar-header
          button(type="button", class="navbar-toggle", data-toggle="collapse", data-target=".navbar-collapse")
            span.sr-only Toggle navigation
            span.icon-bar
            span.icon-bar
            span.icon-bar
          a(class="navbar-brand", href="index.html") MuPlayer
        .collapse.navbar-collapse
          ul.nav.navbar-nav
            if currentName == 'Main'
                li.active
                  a(href="#") 首页
            else
                li
                    a(href="index.html") 首页
            li
              a(href="demo.html") 示例
            if currentName != 'Main'
              li.active
                a(href="#") API文档
            else
                li
                  a(href="api.html") API文档
        a(class="github", target="_blank", href="https://github.com/Baidu-Music-FE/muplayer")
          i
          | View On GitHub

    section.jumbotron
      .container
        h1 <em>Mu</em><span>Player</span>『百度音乐播放内核』
        p  —— 跨平台、轻量级的音频播放解决方案。
        if currentName == 'Main'
            ul.advantages
                li
                  i.glyphicon.glyphicon-ok
                  | 多端（PC & WebApp）通用，统一的API调用方式
                li
                  i.glyphicon.glyphicon-ok
                  | HTML5 Audio与Flash内核的平滑切换（支持IE 6在内的所有常见浏览器）
                li
                  i.glyphicon.glyphicon-ok
                  | 文档完善，API设计灵活简洁
                li
                  i.glyphicon.glyphicon-ok
                  | 针对WebApp端的优化打包，节省加载资源
                li
                  i.glyphicon.glyphicon-ok
                  | 百度多条产品线上实际应用，稳定可靠

    section.container.bs-docs-container
      if symbols.length
        .row
          .col-md-3
            .bs-sidebar.affix-top.hidden-print
              ul.nav.bs-sidenav
                each symbol in symbols
                  li
                    a(href='#'+symbol.name) #{symbol.name}
          .col-md-9
            mixin mainContent
      else
        mixin mainContent

    footer.bs-footer
      .container
        p <code>MuPlayer</code>:
          a(href="https://github.com/Baidu-Music-FE/muplayer", target="_blank") https://github.com/Baidu-Music-FE/muplayer
        p.copyright
          | Copyright (c) 2014
          a(target="_blank", href="http://labs.music.baidu.com") @MusicLab
          a(target="_blank", href="http://weibo.com/musicfe") @音乐前端

    script(src="bower_components/jquery/jquery.min.js")
    script(src="bower_components/bootstrap/dist/js/bootstrap.min.js")
    script(src="bower_components/prism/prism.js")
    script(src="bower_components/prefixfree/prefixfree.min.js")
    script.
      $(function() {
        var $win = $(window),
          $body = $(document.body),
          $sideBar = $('.bs-sidebar'),
          navHeight = $('.bs-docs-nav').outerHeight(true) + 10;

        $body.scrollspy({
          target: '.bs-sidebar',
          offset: navHeight
        });

        $win.on('load', function() {
          $body.scrollspy('refresh');
        });

        setTimeout(function() {
          $sideBar.affix({
            offset: {
              top: function() {
                var offsetTop = $sideBar.offset().top;
                return (this.top = offsetTop - navHeight);
              },
              bottom: function() {
                return (this.bottom = $('.bs-footer').outerHeight(true));
              }
            }
          });
        }, 100);

        $sideBar.on('click', 'a[href^=#]', function() {
          var id = $(this).attr('href').substr(1),
            top = $('#'+ id).offset().top - navHeight + 10;

          $('html, body').animate({
            scrollTop: top
          }, 300);

          return false;
        });
      });

    div(style="display: none")
      script.
        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F89a467ff5d4c7c906a933623c7db27bb'%3E%3C/script%3E"));

        try {
          if (console && console.log) {
            console.log('加入百度音乐前端，跟我们做些有挑战的趣事？');
            console.info && console.info('简历请发 %c musicfe-hr@baidu.com', 'color: #c7254e');
          }
        } catch (e) {}
