Team:UCLA/sams extra css

From 2014.igem.org

(Difference between revisions)
Line 1: Line 1:
-
<html>
+
{{:Team:UCLA/Template/Javascript}}
-
<head>
+
{{:Team:UCLA/Template/CSS_test}}
-
<style>
+
-
#c {
+
-
 
+
-
    margin: 0px auto 0;
+
-
}
+
-
</style>
+
-
<script>
+
-
var physics_accuracy  = 3,
+
-
    mouse_influence  = 20,
+
-
    mouse_cut        = 5,
+
-
    gravity          = 1150,
+
-
    cloth_height      = 10,
+
-
    cloth_width      = 10,
+
-
    start_y          = 20,
+
-
    spacing          = 14,
+
-
    tear_distance    = 60;
+
 +
<html lang="en">
 +
  <head>
 +
    <!-- META TAGS -->
 +
    <meta charset="utf-8">
 +
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
 +
    <meta name="viewport" content="width=device-width, initial-scale=1">
 +
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
 +
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
 +
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
 +
    <link href="css/bootstrap.min.css" rel="stylesheet">
 +
    <link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'>
 +
    <title>iGEM UCLA</title>
-
window.requestAnimFrame =
+
     <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
-
     window.requestAnimationFrame ||
+
     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
-
     window.webkitRequestAnimationFrame ||
+
     <!--[if lt IE 9]>
-
     window.mozRequestAnimationFrame ||
+
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
-
    window.oRequestAnimationFrame ||
+
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
-
    window.msRequestAnimationFrame ||
+
     <![endif]-->
-
     function (callback) {
+
  </head>
-
        window.setTimeout(callback, 1000 / 60);
+
-
};
+
-
var canvas,
 
-
    ctx,
 
-
    cloth,
 
-
    boundsx,
 
-
    boundsy,
 
-
    mouse = {
 
-
        down: false,
 
-
        button: 1,
 
-
        x: 0,
 
-
        y: 0,
 
-
        px: 0,
 
-
        py: 0
 
-
    };
 
-
var Point = function (x, y) {
+
<body>
 +
<!-- MAIN MENU BAR-->
 +
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
 +
  <div class="container">
 +
    <!-- Brand and toggle get grouped for better mobile display -->
 +
    <div class="navbar-header">
 +
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
 +
        <span class="sr-only">Toggle navigation</span>
 +
        <span class="icon-bar"></span>
 +
        <span class="icon-bar"></span>
 +
        <span class="icon-bar"></span>
 +
      </button>
 +
      <a class="navbar-brand" href="#">UCLA iGEM</a>
 +
    </div>
-
     this.x      = x;
+
     <!-- Collect the nav links, forms, and other content for toggling -->
-
     this.y      = y;
+
     <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
-
    this.px    = x;
+
-
    this.py    = y;
+
-
    this.vx    = 0;
+
-
    this.vy    = 0;
+
-
    this.pin_x  = null;
+
-
    this.pin_y  = null;
+
-
   
+
-
    this.constraints = [];
+
-
};
+
-
Point.prototype.update = function (delta) {
+
      <ul class="nav navbar-nav">
 +
        <li class="active"><a href="/Team:UCLA">Home</a></li>
 +
        <li class="dropdown">
 +
          <a href="/Team:UCLA/Team" class="dropdown-toggle" data-toggle="dropdown">Team<span class="caret"></span></a>
 +
          <ul class="dropdown-menu" role="menu">
 +
            <li><a href="/Team:UCLA/meet_the_team">Meet the Team</a></li>
 +
            <li><a href="https://igem.org/Team.cgi?year=2014&team_name=UCLA">Official Profile</a></li>
 +
          </ul>
 +
        </li>
 +
        <li class="dropdown">
 +
          <a href="/Team:UCLA/Project" class="dropdown-toggle" data-toggle="dropdown">Project<span class="caret"></span></a>
 +
          <ul class="dropdown-menu" role="menu">
 +
            <li><a href="/Team:UCLA/Project/Customizing Silk">Customizing Silk Properties</a></li>
 +
    <li><a href="/Team:UCLA/Project/Functionalizing Fibers">Functionalizing Fibers</a></li>
 +
    <li><a href="/Team:UCLA/Project/Spinning Silk">Spinning Silk</a></li>
 +
            <li><a href="#">Human Practices</a></li>
 +
          </ul>
 +
        </li>
 +
        <li class="dropdown">
 +
          <a href="/Team:UCLA/Parts" class="dropdown-toggle" data-toggle="dropdown">Parts<span class="caret"></span></a>
 +
          <ul class="dropdown-menu" role="menu">
 +
    <li><a href="#">Page1</a></li>
 +
    <li><a href="#">Page2</a></li>
 +
    <li><a href="#">Page3</a></li>
 +
          </ul>
 +
        </li>
 +
        <li><a href="/Team:UCLA/Modeling">Modeling</a></li>
 +
        <li class="dropdown">
 +
          <a href="/Team:UCLA/Notebook" class="dropdown-toggle" data-toggle="dropdown">Notebook<span class="caret"></span></a>
 +
          <ul class="dropdown-menu" role="menu">
 +
            <li><a href="/Team:UCLA/Notebook/Protocols">Protocols</a></li>
 +
    <li><a href="/Team:UCLA/Notebook/Calendar">Calendar</a></li>
 +
    <li><a href="/Team:UCLA/Notebook/Weekly Notes">Weekly Notes</a></li>
 +
          </ul>
 +
        </li>
 +
        <li><a href="/Team:UCLA/Safety">Safety</a></li>
 +
        <li><a href="/Team:UCLA/Attributions">Attributions</a></li>
 +
      </ul>
-
     if (mouse.down) {
+
      <ul class="nav navbar-nav navbar-right">
 +
        <a href="https://2014.igem.org/Main_Page"><img src="https://static.igem.org/mediawiki/igem.org/6/60/Igemlogo_300px.png" width="55px"/>
 +
      </ul>
 +
     </div><!-- /.navbar-collapse -->
 +
  </div><!-- /.container-fluid -->
 +
</nav><br>
-
        var diff_x = this.x - mouse.x,
+
<!--SLIDING SIDE BAR-->
-
            diff_y = this.y - mouse.y,
+
<div id="wrapper">
-
            dist = Math.sqrt(diff_x * diff_x + diff_y * diff_y);
+
-
         if (mouse.button == 1) {
+
         <!-- Sidebar -->
 +
        <div id="sidebar-wrapper">
 +
            <nav id="spy">
 +
                <ul class="sidebar-nav nav">
 +
                    <li>
 +
                        <a href="#home"><span class="fa fa-home solo">Home</span></a>
 +
                    </li>
 +
                    <li>
 +
                        <a href="#anch1" data-scroll>
 +
                            <span class="fa fa-anchor solo">Anchor 1</span>
 +
                        </a>
 +
                    </li>
 +
                    <li>
 +
                        <a href="#anch2" data-scroll>
 +
                            <span class="fa fa-anchor solo">Anchor 2</span>
 +
                        </a>
 +
                    </li>
 +
                    <li>
 +
                        <a href="#anch3" data-scroll>
 +
                            <span class="fa fa-anchor solo">Anchor 3</span>
 +
                        </a>
 +
                    </li>
 +
                    <li>
 +
                        <a href="#anch4" data-scroll>
 +
                            <span class="fa fa-anchor solo">Anchor 4</span>
 +
                        </a>
 +
                    </li>
 +
                </ul>
 +
            </nav>
 +
        </div>
-
             if (dist < mouse_influence) {
+
        <!-- Page content -->
-
                this.px = this.x - (mouse.x - mouse.px) * 1.8;
+
        <div id="page-content-wrapper">
-
                 this.py = this.y - (mouse.y - mouse.py) * 1.8;
+
             <div class="content-header">
-
            }
+
              <h1>                   
 +
                  <a id="menu-toggle" href="#" class="glyphicon glyphicon-hand-left btn-menu toggle">
 +
                  </a>
 +
            Guided Tour
 +
                 </h1>
 +
            </div>
 +
            <div class="page-content inset" data-spy="scroll" data-target="#spy">
 +
<!-- BACK-TO-TOP BUTTON -->
 +
<div class="scroll-top-wrapper ">
 +
  <span class="scroll-top-inner">
 +
<i class="fa fa-2x fa-chevron-circle-up"></i>
 +
  </span>
 +
</div>
 +
       
-
        } else if (dist < mouse_cut) this.constraints = [];
+
</div>
-
    }
+
</div>
 +
</body>
-
    this.add_force(0, gravity);
+
<!--SLIDING SIDE BAR-->
 +
<script>
 +
$("#menu-toggle").click(function(e) {
 +
        e.preventDefault();
 +
        $("#wrapper").toggleClass("active");
 +
    });
-
     delta *= delta;
+
     $('body').scrollspy({ target: '#spy', offset:80});
-
    nx = this.x + ((this.x - this.px) * .99) + ((this.vx / 2) * delta);
+
-
    ny = this.y + ((this.y - this.py) * .99) + ((this.vy / 2) * delta);
+
-
     this.px = this.x;
+
     $('a[href*=#]:not([href=#])').click(function() {
-
    this.py = this.y;
+
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') || location.hostname == this.hostname) {
-
    this.x = nx;
+
            var target = $(this.hash);
-
    this.y = ny;
+
            target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
-
 
+
            if (target.length) {
-
    this.vy = this.vx = 0
+
                $('html,body').animate({
-
};
+
                    scrollTop: target.offset().top
-
 
+
                }, 1000);
-
Point.prototype.draw = function () {
+
                return false;
-
 
+
             }
-
    if (!this.constraints.length) return;
+
-
 
+
-
    var i = this.constraints.length;
+
-
    while (i--) this.constraints[i].draw();
+
-
};
+
-
 
+
-
Point.prototype.resolve_constraints = function () {
+
-
 
+
-
    if (this.pin_x != null && this.pin_y != null) {
+
-
 
+
-
        this.x = this.pin_x;
+
-
        this.y = this.pin_y;
+
-
        return;
+
-
    }
+
-
 
+
-
    var i = this.constraints.length;
+
-
    while (i--) this.constraints[i].resolve();
+
-
 
+
-
    this.x > boundsx ? this.x = 2 * boundsx - this.x : 1 > this.x && (this.x = 2 - this.x);
+
-
    this.y < 1 ? this.y = 2 - this.y : this.y > boundsy && (this.y = 2 * boundsy - this.y);
+
-
};
+
-
 
+
-
Point.prototype.attach = function (point) {
+
-
 
+
-
    this.constraints.push(
+
-
        new Constraint(this, point)
+
-
    );
+
-
};
+
-
 
+
-
Point.prototype.remove_constraint = function (constraint) {
+
-
 
+
-
    this.constraints.splice(this.constraints.indexOf(constraint), 1);
+
-
};
+
-
 
+
-
Point.prototype.add_force = function (x, y) {
+
-
 
+
-
    this.vx += x;
+
-
    this.vy += y;
+
-
};
+
-
 
+
-
Point.prototype.pin = function (pinx, piny) {
+
-
    this.pin_x = pinx;
+
-
    this.pin_y = piny;
+
-
};
+
-
 
+
-
var Constraint = function (p1, p2) {
+
-
 
+
-
    this.p1    = p1;
+
-
    this.p2    = p2;
+
-
    this.length = spacing;
+
-
};
+
-
 
+
-
Constraint.prototype.resolve = function () {
+
-
 
+
-
    var diff_x  = this.p1.x - this.p2.x,
+
-
        diff_y  = this.p1.y - this.p2.y,
+
-
        dist    = Math.sqrt(diff_x * diff_x + diff_y * diff_y),
+
-
        diff    = (this.length - dist) / dist;
+
-
 
+
-
    if (dist > tear_distance) this.p1.remove_constraint(this);
+
-
 
+
-
    var px = diff_x * diff * 0.5;
+
-
    var py = diff_y * diff * 0.5;
+
-
 
+
-
    this.p1.x += px;
+
-
    this.p1.y += py;
+
-
    this.p2.x -= px;
+
-
    this.p2.y -= py;
+
-
};
+
-
 
+
-
Constraint.prototype.draw = function () {
+
-
 
+
-
    ctx.moveTo(this.p1.x, this.p1.y);
+
-
    ctx.lineTo(this.p2.x, this.p2.y);
+
-
};
+
-
 
+
-
var Cloth = function () {
+
-
 
+
-
    this.points = [];
+
-
 
+
-
    var start_x = canvas.width / 2 - cloth_width * spacing / 2;
+
-
 
+
-
    for (var y = 0; y <= cloth_height; y++) {
+
-
 
+
-
        for (var x = 0; x <= cloth_width; x++) {
+
-
 
+
-
            var p = new Point(start_x + x * spacing, start_y + y * spacing);
+
-
 
+
-
            x != 0 && p.attach(this.points[this.points.length - 1]);
+
-
             y == 0 && p.pin(p.x, p.y);
+
-
            y != 0 && p.attach(this.points[x + (y - 1) * (cloth_width + 1)])
+
-
 
+
-
            this.points.push(p);
+
         }
         }
-
     }
+
     });
-
};
+
</script>
-
 
+
<!--MAIN NAVBAR-->
-
Cloth.prototype.update = function () {
+
<script>
-
 
+
$('.dropdown').hover(function(){  
-
    var i = physics_accuracy;
+
  $('.dropdown-toggle', this).trigger('click');  
-
 
+
});
-
    while (i--) {
+
-
        var p = this.points.length;
+
-
        while (p--) this.points[p].resolve_constraints();
+
-
    }
+
-
 
+
-
    i = this.points.length;
+
-
    while (i--) this.points[i].update(.016);
+
-
};
+
-
 
+
-
Cloth.prototype.draw = function () {
+
-
 
+
-
    ctx.beginPath();
+
-
 
+
-
    var i = cloth.points.length;
+
-
    while (i--) cloth.points[i].draw();
+
-
 
+
-
    ctx.stroke();
+
-
};
+
-
 
+
-
function update() {
+
-
 
+
-
    ctx.clearRect(0, 0, canvas.width, canvas.height);
+
-
 
+
-
    cloth.update();
+
-
    cloth.draw();
+
-
 
+
-
    requestAnimFrame(update);
+
-
}
+
-
 
+
-
function start() {
+
-
 
+
-
    canvas.onmousedown = function (e) {
+
-
        mouse.button  = e.which;
+
-
        mouse.px      = mouse.x;
+
-
        mouse.py      = mouse.y;
+
-
        var rect      = canvas.getBoundingClientRect();
+
-
        mouse.x      = e.clientX - rect.left,
+
-
        mouse.y      = e.clientY - rect.top,
+
-
        mouse.down    = true;
+
-
        e.preventDefault();
+
-
    };
+
-
 
+
-
    canvas.onmouseup = function (e) {
+
-
        mouse.down = false;
+
-
        e.preventDefault();
+
-
    };
+
-
 
+
-
    canvas.onmousemove = function (e) {
+
-
        mouse.px  = mouse.x;
+
-
        mouse.py  = mouse.y;
+
-
        var rect  = canvas.getBoundingClientRect();
+
-
        mouse.x  = e.clientX - rect.left,
+
-
        mouse.y  = e.clientY - rect.top,
+
-
        e.preventDefault();
+
-
    };
+
-
 
+
-
    canvas.oncontextmenu = function (e) {
+
-
        e.preventDefault();
+
-
    };
+
-
 
+
-
    boundsx = canvas.width - 1;
+
-
    boundsy = canvas.height - 1;
+
-
 
+
-
    ctx.strokeStyle = '#888';
+
-
 
+
-
    cloth = new Cloth();
+
-
 
+
-
    update();
+
-
}
+
-
 
+
-
window.onload = function () {
+
-
 
+
-
    canvas  = document.getElementById('c');
+
-
    ctx    = canvas.getContext('2d');
+
-
 
+
-
    canvas.width  = 150;
+
-
    canvas.height = 180;
+
-
 
+
-
    start();
+
-
};
+
</script>
</script>
-
</head>
 
-
 
-
<body>
 
-
<canvas id="c"></canvas>
 
-
 
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
 
-
 
-
</body>
 
</html>
</html>

Revision as of 21:21, 11 August 2014

iGEM UCLA


Guided Tour