Difference between revisions of "Team:USTC/Composite Part"

Line 1: Line 1:
<html>
+
var $container = $('#ui_article');
  <head>
+
var $pageTitle = "Composite Parts";
    <meta charset="utf-8">
+
var $pageIcon = "cubes icon";
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
+
 
    <title>Modeling</title>
+
var $firstHeaders = $container.find('div.ribbon');
    <!--<link rel="stylesheet" type="text/css" class="ui" href="semantic.min.css">-->
+
//$firstHeaders.addClass("ui dividing header");
    <link rel="stylesheet" type="text/css" href="https://2016.igem.org/Template:USTC/semantics?action=raw&ctype=text/css">
+
$firstHeaders.attr("style","padding-top:30px;");
    <style>
+
var $secondHeaders = $container.find('h3');
    /********************Dealing with default Mediawiki setting*******************/
+
 
    #top_title {
+
var getSafeId = function($element){
    display:none;
+
  return window.escape(getSafeName(getText($element)));
    position:absolute;
+
}
    }
+
var getSafeName = function(text) {
    #content {
+
  return text.replace(/\s+/g, '-').replace(/[^-,'A-Za-z0-9]+/g, '').toLowerCase();
    padding:0px; width:auto; margin-top:-11px; margin-left:0px;
+
};
    }
+
var getText = function($element) {
    #globalWrapper{
+
  $element = ($element.find('a').not('.label, .anchor').length > 0) ? $element.find('a') : $element;
    }
+
  var $text = $element.contents().filter(function() {
    body {
+
     return this.nodeType == 3;
    }
+
  });
    #bodyContent {
+
  return ($text.length > 0) ? $text[0].nodeValue.trim() : $element.find('a').text().trim();
    }
+
};
    div#top_menu_14{
+
 
    height:21px;
+
 
    border-bottom-color:#383838;
+
var createMenu = function() {
    }
+
  var
    div#top_menu_under{
+
     html = '',
   
+
     pageTitle = $pageTitle,
    }
+
     title = pageTitle.charAt(0).toUpperCase() + pageTitle.slice(1),
    div#globalWrapper{
+
     icon = $pageIcon,
    padding-bottom: 0;
+
     $sticky,
    }
+
     $rail;
    #top_menu_under{
+
  $firstHeaders
    height:0;
+
     .each(function(index) {
    }
+
      var
    #sideMenu{
+
        $currentHeader = $(this),
    display:none;
+
         $nextElements = $currentHeader.nextUntil('div.ribbon'),
    position:fixed;
+
         $secondHeadersBeforNextElement = $nextElements.filter('h3'),
    left:220px;
+
         activeClass = (index === 0) ? 'active ' : '',
    }
+
        id = getSafeId($currentHeader),
    /******************************************************************************/
+
        $anchor = $('<a />').addClass('anchor').attr('id', id);
    </style>
+
        $currentHeader.append($anchor);
    <style>
+
      html += '<div class="item">';
    div.ui.inverted.vertical.sticky.basic.menu a.item{
+
      if ($secondHeadersBeforNextElement.length === 0) {
    -webkit-transition: background-color 0.6s , color 0.6s;
+
        html += '<a class="' + activeClass + 'title" href="#' + id + '"><b>' + $(this).text() + '</b></a>';
    }
+
       } else {
    div.ui.inverted.vertical.sticky.basic.menu a.item:hover{
+
         html += '<a class="' + activeClass + 'title"><i class="dropdown icon"></i> <b>' + $(this).text() + '</b></a>';
    background-color: #FFFA99;
+
       }
    color:#6E47B2;
+
       if ($secondHeadersBeforNextElement.length > 0) {
    }
+
         html += '<div class="' + activeClass + 'content menu">';
    p{
+
        $secondHeadersBeforNextElement
    font-family: 'Lato'!important;
+
           .each(function() {
    font-size:16px !important;
+
            var
    line-height: 150%;
+
              $currentSecondHeader = $(this),
    }
+
              childId = id + '-' +getSafeId($currentSecondHeader),
    </style>
+
              $anchor = $('<a />').addClass('anchor').attr('id', childId);
   
+
              $currentSecondHeader.after($anchor);
    <!--For multiple devices-->
+
              html += '<a class="item" href="#' + childId + '">' + getText($currentSecondHeader) + '</a>';
    <style>
+
          });
    @media only screen
+
         html += '</div>';
    and (min-width: 1025px){
+
       }
     div#menuForTablet{
+
       html += '</div>';
    display:none;
+
    });
    }
+
   $followMenu = $('<div />')
    div#main_page_content{
+
    .addClass('ui vertical following fluid accordion text menu')
    margin-top:-13px;
+
    .html(html);
    left:210px;
+
 
    max-width: 1070px;
+
   $sticky = $('<div />')
    }
+
    .addClass('ui sticky')
    #ui_article{
+
    .html($followMenu)
    width:64%;
+
    //.prepend($advertisement)
    }
+
     .prepend('<h3 class="ui header"><i class="' + icon + '"></i>' + '<div class="content">' + title + '</div>' '</h3>');
    }
+
  $rail = $('<div />')
    @media only screen
+
    .addClass('ui dividing right rail')
    and (max-width : 1024px)
+
    .html($sticky)
    and (orientation : landscape) {
+
    .prependTo($container);
    div#main_page_content{
+
  $sticky.sticky({
    margin-top:40px;
+
    silent: true,
    }
+
    context: $container,
    div#menuForComputer{
+
    offset: 70
    display:none;
+
  });
    width:0;
+
  $followMenu
    height:0;
+
    .accordion({
    }
+
      exclusive: false,
    #ui_article{
+
      animateChildren: false,
    width:63%;
+
      onChange: function() {
     }
+
        $('.ui.sticky').sticky('refresh');
     }
+
      }
     @media only screen
+
    })
    and (max-width : 1024px)
+
    .find('.menu a[href], .title[href]')
    and (orientation : portrait) {
+
    .on('click', function(event) {
     div#main_page_content{
+
            var id = $(this).attr('href').replace('#', '')
     margin-top:40px;
+
               , $element = $('#' + id)
     }
+
               , position = $element.offset().top - 60;
    div#menuForComputer{
+
            $element.addClass('active');
    display:none;
+
            $('html, body').animate({
    width:0;
+
                 scrollTop: position
     height:0;
+
             }, 500);
    }
+
             location.hash = '#' + id;
    #ui_article{
+
             event.stopImmediatePropagation();
    width:63%;
+
             event.preventDefault();
    }
+
            return false;
    }
+
         });
    </style>
+
};
  </head>
+
 
 
+
var createWayPoints = function(){
 
+
  $firstHeaders
  <body>
+
    .visibility({
   
+
      observeChanges: false,
    <div class="ui inverted vertical sidebar basic menu" style="border-radius:0; background-color: #44a17d; padding-top:9px;font-size:medium;">
+
      once: false,
      <div class="item">
+
      offset: 60,
         <img class="ui image" src="https://static.igem.org/mediawiki/2016/3/36/T--USTC--a_prion%27s_life.png">
+
      onTopPassed: function() {
      </div>
+
                 var $section = $(this)
      <a class="item" href="https://2016.igem.org/Team:USTC">Home </a>
+
                   , index = $firstHeaders.index($section)
      <div class="item">
+
                   , $followSection = $followMenu.children('.item')
         <div class="header">Project</div>
+
                   , $activeSection = $followSection.eq(index)
         <div class="menu">
+
                   , isActive = $activeSection.hasClass('active');
          <a class="item" id="Description" href="https://2016.igem.org/Team:USTC/Description"> ★  Description </a>
+
                 if (!isActive) {
          <a class="item" href="https://2016.igem.org/Team:USTC/Design"> ★ Design </a>
+
                     $followSection.filter('.active').removeClass('active');
          <a class="item" href="https://2016.igem.org/Team:USTC/Proof"> ★ Proof of Concept </a>
+
                     $activeSection.addClass('active');
          <a class="item" href="https://2016.igem.org/Team:USTC/Demonstrate"> ★ Demonstrate </a>
+
                    $followMenu.accordion('open', index);
          <a class="item" href="https://2016.igem.org/Team:USTC/Results"> Results </a>
+
                 }
          <a class="item" href="https://2016.igem.org/Team:USTC/Notebook"> Notebook </a>
+
                 if(index -1 > -1){
          <a class="item" href="https://2016.igem.org/Team:USTC/Spin_off"> Spin-off </a>
+
                  $followMenu.accordion('close', index - 1);
        </div>
+
                }
      </div>
+
             },
      <div class="item">
+
       onTopPassedReverse: function() {
        <div class="header">Parts</div>
+
                var $menuItems = $followMenu.children('.item')
        <div class="menu">
+
                  , $section = $menuItems.filter('.active')
          <a class="item" href="https://2016.igem.org/Team:USTC/Basic_Part"> ★ Basic Parts </a>
+
                  , index = $menuItems.index($section);
          <a class="item" href="https://2016.igem.org/Team:USTC/Composite_Part"> ★ Composite Parts </a>
+
                if ($section.prev().length > 0) {
          <a class="item" href="https://2016.igem.org/Team:USTC/Part_Collection"> ★ Part Collection </a>
+
                    $section.removeClass('active').prev('.item').addClass('active');
        </div>
+
                    $followMenu.accordion('open', index - 1);
      </div>
+
                    $followMenu.accordion('close', index );
      <a class="item" href="https://2016.igem.org/Team:USTC/Safety">Safety </a>
+
                }
      <a class="item" href="https://2016.igem.org/Team:USTC/Attributions">Attributions </a>
+
            }
       <div class="item">
+
    });
         <div class="header">Human Practices</div>
+
    $secondHeaders.visibility({
        <div class="menu">
+
       observeChanges: false,
          <a class="item" href="https://2016.igem.org/Team:USTC/Human_Practices"> Human Practices </a>
+
       once: false,
          <a class="item" href="https://2016.igem.org/Team:USTC/HP/Silver">★ Silver </a>
+
       offset: 60,
          <a class="item" href="https://2016.igem.org/Team:USTC/HP/Gold">★ Gold </a>
+
       onTopPassed: function() {
          <a class="item" href="https://2016.igem.org/Team:USTC/Integrated_Practices"> ★ Integrated Practices </a>
+
                var $section = $(this)
          <a class="item" href="https://2016.igem.org/Team:USTC/Engagement">★ Engagement </a>
+
                  , index = $secondHeaders.index($section)
        </div>
+
                  , $allSecondHeaderMenu = $followMenu.children('.item').children('.content.menu').children('a.item')
       </div>
+
                  , $activeSecondHeader = $allSecondHeaderMenu.eq(index);
       <div class="item">
+
                  // , $activeParentHeader = $activeSecondHeader.parent()
         <div class="header">Awards</div>
+
                  // , isParentFirstHeaderMenuActive = $activeParentHeader.hasClass('active')
        <div class="menu">
+
                  // , $menuItems = $followMenu.children('.item');
           <a class="item" href="https://2016.igem.org/Team:USTC/Entrepreneurship"> ★ Entrepreneurship </a>
+
               
          <a class="item" href="https://2016.igem.org/Team:USTC/Hardware"> ★ Hardware </a>
+
                    $allSecondHeaderMenu.filter('.active').removeClass('active');
          <a class="item" href="https://2016.igem.org/Team:USTC/Software">★ Software </a>
+
                    $activeSecondHeader.addClass('active');
          <a class="item" href="https://2016.igem.org/Team:USTC/Measurement">★  Measurement </a>
+
                // if (!isParentFirstHeaderMenuActive) {
          <a class="item" href="https://2016.igem.org/Team:USTC/Model">★ Model </a>
+
                //  index = $followMenu.children().index($activeParentHeader.parent());
         </div>
+
                //    $followMenu.accordion('open', index);
       </div>
+
                // }
       <div class="item">
+
            },
        <div class="header">Team</div>
+
       onTopPassedReverse: function() {
        <div class="menu">
+
                var $allSecondHeaderMenu = $followMenu.children('.item').children('.content.menu').children('a.item')
          <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> Members   </a>
+
                  , $section = $allSecondHeaderMenu.filter('.active')
          <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> Sponsor  </a>
+
                  , index = $allSecondHeaderMenu.index($section);
          <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> About USTC  </a>
+
                if (index > 0) {
          <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> Acknowledgements  </a>
+
                    $section.removeClass('active').prev('.item').addClass('active');
          <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> Gallery   </a>
+
                    $allSecondHeaderMenu.eq(index-1).addClass('active');
          <a class="item" href="https://2016.igem.org/Team:USTC/Collaborations">★  Collaborations </a>
+
                }
        </div>
+
            }
      </div>
+
     });
      <a class="item" href="https://2016.igem.org/Team:USTC/Editing_Trial">Editing Trial </a>
+
}
      <a class="item" href="https://2016.igem.org/Team:USTC/Editing_Trial2">Editing Trial 2 </a>
+
      <a class="item" href="https://2016.igem.org/Team:USTC/Editing_Trial3">Editing Trial 3 </a>
+
     </div>
+
   
+
   
+
    <div class="pusher">
+
      <div class="ui menu top fixed" id="menuForTablet" style="background-color: #FBBD08; top:21px;">
+
        <div class="ui fluid container">
+
          <a class="item" id="sidebarMenuTrigger">Navigation<i class="right arrow icon"></i></a>
+
          <div class="right item">A Prion's Life</div>
+
        </div>
+
      </div>
+
      <div class="ui basic segment" id="main_page_content" style="margin-bottom:0;padding:0 0 20px 0;">
+
        <div class="ui left attached rail" id="menuForComputer" style=" width:210px;">
+
          <div class="ui inverted vertical sticky basic menu" style="border-radius:0; background-color: #44a17d; padding-top:9px;font-size:medium;">
+
            <div class="item">
+
              <img class="ui image" src="https://static.igem.org/mediawiki/2016/3/36/T--USTC--a_prion%27s_life.png">
+
            </div>
+
            <a class="item" href="https://2016.igem.org/Team:USTC">Home </a>
+
            <div class="item">
+
              <div class="header">Project</div>
+
              <div class="menu">
+
                <a class="item" id="Description" href="https://2016.igem.org/Team:USTC/Description"> ★  Description </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Design"> ★ Design </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Proof"> ★ Proof of Concept </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Demonstrate"> ★ Demonstrate </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Results"> Results </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Notebook"> Notebook </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Spin_off"> Spin-off </a>
+
              </div>
+
            </div>
+
            <div class="item">
+
              <div class="header">Parts</div>
+
              <div class="menu">
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Basic_Part"> ★ Basic Parts </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Composite_Part"> ★ Composite Parts </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Part_Collection"> ★ Part Collection </a>
+
              </div>
+
            </div>
+
            <a class="item" href="https://2016.igem.org/Team:USTC/Safety">Safety </a>
+
            <a class="item" href="https://2016.igem.org/Team:USTC/Attributions">Attributions </a>
+
            <div class="item">
+
              <div class="header">Human Practices</div>
+
              <div class="menu">
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Human_Practices"> Human Practices </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/HP/Silver">★ Silver </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/HP/Gold">★ Gold </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Integrated_Practices"> ★ Integrated Practices </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Engagement">★ Engagement </a>
+
              </div>
+
            </div>
+
            <div class="item">
+
              <div class="header">Awards</div>
+
              <div class="menu">
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Entrepreneurship"> ★ Entrepreneurship </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Hardware"> ★ Hardware </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Software">★ Software </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Measurement">★  Measurement </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Model">★ Model </a>
+
               </div>
+
            </div>
+
            <div class="item">
+
               <div class="header">Team</div>
+
              <div class="menu">
+
                <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> Members  </a>
+
                <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> Sponsor  </a>
+
                <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> About USTC  </a>
+
                 <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> Acknowledgements  </a>
+
                <a class="item" href=" https://2016.igem.org/Team:USTC/Team"> Gallery  </a>
+
                <a class="item" href="https://2016.igem.org/Team:USTC/Collaborations">★  Collaborations </a>
+
              </div>
+
             </div>
+
             <a class="item" href="https://2016.igem.org/Team:USTC/Editing_Trial">Editing Trial </a>
+
             <a class="item" href="https://2016.igem.org/Team:USTC/Editing_Trial2">Editing Trial 2 </a>
+
             <a class="item" href="https://2016.igem.org/Team:USTC/Editing_Trial3">Editing Trial 3 </a>
+
          </div>
+
         </div>
+
       
+
        <!--Page content starts here-->
+
        <div class="ui basic segment">
+
          <div class="ui basic segment" style="padding-top: 20px; font-size:xx-large;">
+
            <h1 class="ui center aligned icon header">
+
            <i class="circular cubes icon"></i>
+
            <div class="content">Composite Parts
+
              <div class="sub header">Designed by joint hands</div>
+
            </div>
+
            </h1>
+
          </div>
+
          <div class="ui basic segment">
+
            <h3 class="ui center aligned header">Leaders</h3>
+
            <div class="ui five column grid">
+
              <div class="column"></div>
+
              <div class="column">
+
                 <div class="ui fluid card">
+
                   <div class="image">
+
                    <img src="https://static.igem.org/mediawiki/2016/d/de/T--USTC--ChengleZhang.jpeg">
+
                   </div>
+
                  <div class="content">
+
                    <div class="description">Chengle Zhang</div>
+
                  </div>
+
                </div>
+
              </div>
+
              <div class="column">
+
                <div class="ui fluid card">
+
                  <div class="image">
+
                    <img src="https://static.igem.org/mediawiki/2016/b/b2/T--USTC--KaiyueMa.jpeg">
+
                   </div>
+
                  <div class="content">
+
                    <div class="description">Kaiyue Ma</div>
+
                   </div>
+
                </div>
+
              </div>
+
              <div class="column">
+
                 <div class="ui fluid card">
+
                  <div class="image">
+
                     <img src="https://static.igem.org/mediawiki/2016/5/5d/T--USTC--YinWu.jpeg">
+
                  </div>
+
                  <div class="content">
+
                     <div class="description">Yin Wu</div>
+
                  </div>
+
                </div>
+
              </div>
+
              <div class="column"></div>
+
            </div>
+
          </div>
+
        </div>
+
        <div class="ui segment" id="ui_article" style="min-height:800px; margin-left: 35px;margin-top:30px;">
+
         
+
          <div class="ui violet ribbon label header">Composite Parts</div>
+
          <p>A list of composite parts USTC iGEM 2016 have been submitted to the Registry.The main functions of these composite parts are as follows:</p>
+
          <ol>
+
            <li>To compare the fluorescence intensity of sole sfGFP11/sfGFP1-10 and combination of sfGFP11 and sfGFP1-10;</li>
+
            <li>To test the aggregation ability of SUP35.</li>
+
          </ol>
+
          <br/>
+
          <div class="ui teal ribbon label header">List of Composite Parts</div>
+
          <table class="ui celled table" style="border-radius: 5px;">
+
            <thead>
+
              <tr>
+
                 <th>Code Name</th>
+
                 <th>Parts Name</th>
+
                <th>Type</th>
+
                <th>Function</th>
+
              </tr>
+
            </thead>
+
            <tbody>
+
              <tr>
+
                <td>BBa_K2009363</td>
+
                <td>PGAL+GFP</td>
+
                <td>Reporter</td>
+
                <td> A reporter in the Propri-ontein system</td>
+
              </tr>
+
              <tr>
+
                <td>BBa_K2009602</td>
+
                <td>PR+sfGFP11</td>
+
                <td>Composite</td>
+
                <td>Express the gene sfGFP11 constitutively</td>
+
              </tr>
+
              <tr>
+
                <td>BBa_K2009666</td>
+
                <td>PR+sfGFP1-10</td>
+
                <td>Composite</td>
+
                <td>Express the gene sfGFP1-10 constitutively</td>
+
              </tr>
+
              <tr>
+
                <td>BBa_K2009701</td>
+
                <td>SUP35+sfGFP11</td>
+
                <td>Coding</td>
+
                <td>Assembling to emit brighter green fluorescence</td>
+
              </tr>
+
              <tr>
+
                <td>BBa_K2009233</td>
+
                <td>SUP35+AD</td>
+
                <td>Coding</td>
+
                <td>Binding with BD to activate the promoter GAL1</td>
+
              </tr>
+
              <tr>
+
                <td>BBa_K2009520</td>
+
                <td>SUP35+BD</td>
+
                <td>Coding</td>
+
                <td>Binding with AD to activate the promoter GAL1</td>
+
              </tr>
+
            </tbody>
+
          </table>
+
        </div>
+
        </div><!--End of ui basic segment id="main_page_content"-->
+
        <div style="background-color:#44a17d; height: 400px;">
+
          <p style="color:#fbbd08; font-family:'Lato'; font-size:40px; position:absolute; left:425px;">
+
             <i class="star half empty icon"></i>Let's get it all done!<i class="star icon"></i>
+
          </p>
+
        </div>
+
       </div>
+
      <script src="https://2015.igem.org/common/MathJax-2.5-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+
      <script type="text/javascript" src="https://2016.igem.org/Template:USTC/semanticsjs?action=raw&ctype=text/javascript"></script>
+
      <script type="text/javascript" src="https://2016.igem.org/Template:USTC/CompositeParts_right_menu_js?action=raw&ctype=text/javascript"></script>
+
      <script type="text/javascript">
+
      </script>
+
      <script>
+
      $(document).ready(function(){
+
      $('.ui.sticky.basic.menu').sticky({
+
      context: '#main_page_content'
+
      });
+
      $("a.item#Description").mouseenter(function(){
+
      $(".sticky.note.outline.icon").transition({
+
      animation : 'fly right',
+
      duration : '0.5s'
+
      });
+
      });
+
      $("a.item#Description").mouseleave(function(){
+
       $(".sticky.note.outline.icon").transition({
+
       animation : 'fly right',
+
       duration : '0.5s'
+
       });
+
      //$(this).css({"background-color":"inherit","color":"inherit"});
+
      });
+
      $container.find('img').css('max-width','100%').each(function(){$(this).before($("<br/>")).after($("<br/>"));})
+
      createMenu();
+
      });//End of $(document).ready(function())
+
     
+
      $(window).load(function(){
+
      createWayPoints();
+
      $("div.pusher").prependTo("body");
+
      $("div.sidebar").prependTo("body");
+
      $("div#sideMenu").prependTo("div.pusher");
+
      $("#ui_article").find("span").css("border-style","none");
+
      });
+
       $("#sidebarMenuTrigger").click(function(){
+
      $(".ui.sidebar.menu")
+
      .sidebar('setting', 'transition', 'overlay')
+
      .sidebar('setting', 'mobileTransition', 'overlay')
+
      .sidebar('toggle');
+
      });
+
      </script>
+
     </body>
+
  </html>
+

Revision as of 09:29, 15 October 2016

var $container = $('#ui_article'); var $pageTitle = "Composite Parts"; var $pageIcon = "cubes icon";

var $firstHeaders = $container.find('div.ribbon'); //$firstHeaders.addClass("ui dividing header"); $firstHeaders.attr("style","padding-top:30px;"); var $secondHeaders = $container.find('h3');

var getSafeId = function($element){

 return window.escape(getSafeName(getText($element)));

} var getSafeName = function(text) {

 return text.replace(/\s+/g, '-').replace(/[^-,'A-Za-z0-9]+/g, ).toLowerCase();

}; var getText = function($element) {

 $element = ($element.find('a').not('.label, .anchor').length > 0) ? $element.find('a') : $element;
 var $text = $element.contents().filter(function() {
   return this.nodeType == 3;
 });
 return ($text.length > 0) ? $text[0].nodeValue.trim() : $element.find('a').text().trim();

};


var createMenu = function() {

 var
   html = ,
   pageTitle = $pageTitle,
   title = pageTitle.charAt(0).toUpperCase() + pageTitle.slice(1),
   icon = $pageIcon,
   $sticky,
   $rail;
 $firstHeaders
   .each(function(index) {
     var
       $currentHeader = $(this),
       $nextElements = $currentHeader.nextUntil('div.ribbon'),
       $secondHeadersBeforNextElement = $nextElements.filter('h3'),
       activeClass = (index === 0) ? 'active ' : ,
       id = getSafeId($currentHeader),
       $anchor = $('<a />').addClass('anchor').attr('id', id);
       $currentHeader.append($anchor);
html += '
';
     if ($secondHeadersBeforNextElement.length === 0) {
       html += '<a class="' + activeClass + 'title" href="#' + id + '">' + $(this).text() + '</a>';
     } else {
       html += '<a class="' + activeClass + 'title"> ' + $(this).text() + '</a>';
     }
     if ($secondHeadersBeforNextElement.length > 0) {
html += '';
     }
html += '
';
   });
 $followMenu = $('<div />')
   .addClass('ui vertical following fluid accordion text menu')
   .html(html);
 $sticky = $('<div />')
   .addClass('ui sticky')
   .html($followMenu)
   //.prepend($advertisement)
.prepend('

' + '
' + title + '
' '

');
 $rail = $('<div />')
   .addClass('ui dividing right rail')
   .html($sticky)
   .prependTo($container);
 $sticky.sticky({
   silent: true,
   context: $container,
   offset: 70
 });
 $followMenu
   .accordion({
     exclusive: false,
     animateChildren: false,
     onChange: function() {
       $('.ui.sticky').sticky('refresh');
     }
   })
   .find('.menu a[href], .title[href]')
   .on('click', function(event) {
           var id = $(this).attr('href').replace('#', )
             , $element = $('#' + id)
             , position = $element.offset().top - 60;
           $element.addClass('active');
           $('html, body').animate({
               scrollTop: position
           }, 500);
           location.hash = '#' + id;
           event.stopImmediatePropagation();
           event.preventDefault();
           return false;
       });

};

var createWayPoints = function(){

 $firstHeaders
   .visibility({
     observeChanges: false,
     once: false,
     offset: 60,
     onTopPassed: function() {
               var $section = $(this)
                 , index = $firstHeaders.index($section)
                 , $followSection = $followMenu.children('.item')
                 , $activeSection = $followSection.eq(index)
                 , isActive = $activeSection.hasClass('active');
               if (!isActive) {
                   $followSection.filter('.active').removeClass('active');
                   $activeSection.addClass('active');
                   $followMenu.accordion('open', index);
               }
               if(index -1 > -1){
                 $followMenu.accordion('close', index - 1);
               }
           },
     onTopPassedReverse: function() {
               var $menuItems = $followMenu.children('.item')
                 , $section = $menuItems.filter('.active')
                 , index = $menuItems.index($section);
               if ($section.prev().length > 0) {
                   $section.removeClass('active').prev('.item').addClass('active');
                   $followMenu.accordion('open', index - 1);
                   $followMenu.accordion('close', index );
               }
           }
   });
   $secondHeaders.visibility({
     observeChanges: false,
     once: false,
     offset: 60,
     onTopPassed: function() {
               var $section = $(this)
                 , index = $secondHeaders.index($section)
                 , $allSecondHeaderMenu = $followMenu.children('.item').children('.content.menu').children('a.item')
                 , $activeSecondHeader = $allSecondHeaderMenu.eq(index);
                 // , $activeParentHeader = $activeSecondHeader.parent()
                 // , isParentFirstHeaderMenuActive = $activeParentHeader.hasClass('active')
                 // , $menuItems = $followMenu.children('.item');
               
                   $allSecondHeaderMenu.filter('.active').removeClass('active');
                   $activeSecondHeader.addClass('active');
               // if (!isParentFirstHeaderMenuActive) {
               //  index = $followMenu.children().index($activeParentHeader.parent());
               //     $followMenu.accordion('open', index);
               // }
           },
     onTopPassedReverse: function() {
               var $allSecondHeaderMenu = $followMenu.children('.item').children('.content.menu').children('a.item')
                 , $section = $allSecondHeaderMenu.filter('.active')
                 , index = $allSecondHeaderMenu.index($section);
               if (index > 0) {
                   $section.removeClass('active').prev('.item').addClass('active');
                   $allSecondHeaderMenu.eq(index-1).addClass('active');
               }
           }
   });

}