<!doctype html>
<html>
  <head>
    <link rel="stylesheet" href="http://s3.amazonaws.com/codecademy-content/projects/bootstrap.min.css">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
    <link rel='stylesheet' href='style.css'/>
  </head>
  <body>
    <div class="header">
      <div class="container">
        <img src="http://s3.amazonaws.com/codecademy-content/projects/2/bonsai/logo.svg">
        <h1>Bonsai</h1>
      </div>
    </div>
    
    <div class="main">
      <div class="container">
        <div class="row">
          <div class="col-md-6">
            
            <div class="meme thumbnail">
              <img src="http://s3.amazonaws.com/codecademy-content/projects/2/bonsai/cat.jpg">
              <h1 class="top-caption">U say something?</h1>
              <h1 class="bottom-caption">I'm all ears</h1>
            </div>

          </div>
          <div class="col-md-6">
            
            <div class="tool">
              <h2>Create a meme</h2>
              <form role="form">
                <div class="form-group">
                  <label>Image URL</label>
                  <input id="image-url" type="text" class="form-control">
                </div>
                <div class="form-group">
                  <label>Top text</label>
                  <input id="top-text" type="text" class="form-control">
                </div>
                <div class="form-group">
                  <label>Bottom text</label>
                  <input id="bottom-text" type="text" class="form-control">
                </div>
              </form> 
            </div>

          </div>
        </div>
      </div>
    </div>

    <script src="http://s3.amazonaws.com/codecademy-content/projects/jquery.min.js"></script>
	<script src='script.js'></script>
  </body>
</html>
html, body {
  margin: 0;
  padding: 0;
  font-family: "Open Sans", sans-serif;
}

.header {
  background: #ffe780;
  margin-bottom: 40px;
  padding: 10px 0;
}

.header img {
  width: 90px;
  margin: -10px 10px 0 0;
}

.header h1 {
  margin: 0;
  display: inline-block;
}

.meme {
  position: relative;
}

.top-caption,
.bottom-caption {
  font-family: Impact, sans-serif;
  color: #fff;
  text-shadow: #000 0px 0px 6px;
  text-transform: uppercase;
  text-align: center;
  font-size: 50px;
}

.top-caption {
  top: 10px;
  left: 0;
  right: 0;
  margin: 0 auto;
  position: absolute;
}

.bottom-caption {
  bottom: 10px;
  left: 0;
  right: 0;
  margin: 0 auto;
  position: absolute;
}

.tool h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 25px;
}

.tool form label {
  margin-bottom: 10px;

}

.tool input {
  border-radius: 0;
  border: 0;
  border-bottom: 5px solid #ff7171;
  box-shadow: none;
}

input[type="text"]:focus {
  border: 0;
  border-bottom: 5px solid #ff7171;
  outline: 0;
  box-shadow: none;
}
var main = function() {
    
    $("#top-text").keyup(function() {
        var topcap = $(this).val() || "U SAY SOMETHING?";
        $('.top-caption').text(topcap);
    });
    
    $("#bottom-text").keyup(function() {
        var bottomcap = $(this).val() || "I'M ALL EARS";
        $('.bottom-caption').text(bottomcap);
    });
    
    $("#image-url").keyup(function() {
        var new_image = $(this).val() || "http://lorempixel.com/640/480/cats";
        $('.meme img').attr("src", new_image);
    });
    
}
 
$(document).ready(main);


// a cat img: http://images2.fanpop.com/image/photos/9400000/Funny-Cats-cats-9474201-1600-1200.jpg

// Interesting code from other submissions //
//----------------------------------------//

// from http://www.codecademy.com/minervadreaming/codebits/k8Fh3b/edit
// save the original img and use it if the img field is wiped
    // var oldimgURL = $('.meme img').attr('src');
    // $('#image-url').keyup(function() {
    //     var imgurlInput = $('#image-url').val();
    //     if (imgurlInput.length > 0) {
    //         $('.meme img').attr({src: imgurlInput});
    //     } else {
    //         $('.meme img').attr({src: oldimgURL});
    //     }
    // });
    
// from http://www.codecademy.com/learningruby/codebits/Lf9keL/edit
// added code to restore all fields
    // $('#top-text').keyup(function() {
    //     var top = $(this).val() || "u say something?";
    //     $('.top-caption').text(top);
    // });

Browse more Codebits