Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                

<div ng-app="myApp" class="app">
  <h1>2014 Official Top Cat Election</h1>
  <div ng-controller="catCtrl">
    <form>
     <table>
       <!-- Badge start -->
       <tr ng-repeat="cat in cats" class="candidate">

         <td class="theradio">
          <input type=radio name=topcat value="{{cat.id}}">
         </td>
         <td class="thebadge">
           
           <label>{{cat.name}}</label>
           <div class="candidate-badge"> 
             
             <img ng-src={{cat.img}}>
             <p>{{cat.desc}}
               <p><a ng-href="{{cat.link}}">See full biography</a></p>
             </p>
           </div>
         </td>
       </tr>
    <!-- badge end -->
    </table>
     <input type=submit value="Elect the 2014 Top Cat" class="btn btn-primary btn-lg" ng-click="trickyVote()">
    </form>
    <div id="messages" class="alert alert-success" ><span><img src="http://farm5.static.flickr.com/4088/5126911694_5a5065ed65_m.jpg"></span>{{voter.message}}</div>
    <div class="votetable">
      <table class="table table-striped table-bordered table-hover">
        <tr>
          <th>cat</th>
          <th>votes</th>
        </tr>
        <tr ng-repeat="vote in votes">
          <td>{{vote.name}}</td>
          <td>{{vote.votes}}</td>
        </tr>
      </table>
    </div>
  </div>
</div>


              
            
!

CSS

              
                .app {
  padding-left: 1em;
}

.candidate-badge {
  margin-left: 1.5em;
}
tr.candidate {
  margin: 2em;

  margin-bottom: 2em;
  padding-top: 1em;
  clear: left;
  overflow: auto;
}
tr.candidate input {
  valign: middle;
}
tr.candidate label {
  font-size: 120%;
  font-weight: bold;
  padding-left: 1em;
}
tr.candidate img {
  float: left;
  clear: right;
  max-width: 150px;
  padding-right: 1em;
  padding-bottom: 1em;
}
td.theradio {
  xxx-background: #acacac;
  padding: 1em;
}
td.thebadge {
  border: 1px #ababab dotted;
}
td.theradio input[type="radio"] {
  vertical-align:middle;
  border: 1px red solid;
  background: red;
}
.hilite {
  background: #99dd99;
}
.votetable table td {
  xx-padding: 1em;
}
.votetable {
  margin-top: 1em;
  width: 70%;
}
table {
  margin-bottom: 1em;
}
div#messages {
  display: none;
  margin: 1em;
}
#messages span {
  margin-right: 1em;
}

              
            
!

JS

              
                $("document.ready", function() {
  $("input[type=radio]").on("click", function() {
    $(".hilite").removeClass('hilite');
    $(this).closest('tr').addClass('hilite');  
    
  });
  $("tr").on("click", function() {
    
    $(this).find('input[type=radio]').prop("checked", true);
    $("tr").removeClass("hilite");
    $(this).addClass('hilite');
  });
});


var app = angular.module('myApp',[]);
app.controller("catCtrl", function($scope) {
  $scope.votes = [
    {name: 'Bossy Lynn', votes: 23},
    {name: 'Sherman LeGrande', votes: 0},
    {name: 'Seamus McGraw', votes: 0},
    {name: 'the Weasel', votes: 0}
  ];
  $scope.voter = {
    message:''
  };
  $scope.trickyVote = function() {
    angular.element("tr").removeClass("hilite");
    angular.element("tr:first").addClass("hilite");
    angular.element("tr:first input[type=radio]").prop("checked", true);
    $scope.voter.message="Thanks for voting for Bossy! Every vote counts.";
    //alert("Thanks for voting for Bossy, every vote counts.");
    $scope.votes[0].votes += 1;
    //$scope.voter.showAlert = 1;
    angular.element("#messages").fadeIn('slow');
    //.fadeOut("slow");
    setTimeout(function() {
      // wrap in a $scope.$apply
      $scope.$apply(function() {
        angular.element("#messages").fadeOut("slow");
        //$scope.voter.message = "";
      });
    }, 5000);
    
    
  };
  $scope.cats = [
    {id: 1, name: 'Bossy Lynn', img: 'https://lh4.googleusercontent.com/-yrBY0nt1oyU/U5Ry_GyJGII/AAAAAAAAI38/kKUbqcuB4qU/w1133-h850-no/IMG_20140608_082754.jpg', desc: 'Bossy would make a great Top cat as she has extensive experience making executive decisions.',
     link:'http://sarahpalin2016.com'},
    
    {id: 2, name: 'Seamus McGraw', img: 'https://lh5.googleusercontent.com/-zFy2dnYflwg/U5R7w0AdqqI/AAAAAAAAI8E/Evftg_pwHY0/w1133-h850-no/IMG_20140608_090516.jpg', desc: 'Seamus would prefer you let him outside for a while and you voted for someone else, except perhaps for bossy.', link:'http://crimestoppers.com'},
    
    {id: 3, name: 'Sherman LeGrande', img: 'https://lh3.googleusercontent.com/-EM0yYSG2EdU/S_izY4alGvI/AAAAAAAADuo/DiuGbRsVU8w/w1034-h1378-no/2010-05-22%2B09.30.12.jpg', desc: 'Sherman is a good choice as he has great people skills.', link:'http://people.com'},
    
    {id: 4, name: 'the Weasel', img: 'https://www.gannett-cdn.com/indepth-static-assets/uploads/master/3486479002/fd34d304-b487-42f2-ad89-77b15f545895-ferret-cropped.jpg?width=2160', desc: 'wat?!', link:'http://ferrets.com'}
    

  ];
  
});

              
            
!
999px

Console