cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              

<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>


            
          
!
            
              .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;
}

            
          
!
            
              $("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: 'http://images.nationalgeographic.com/wpf/media-live/photos/000/004/cache/black-footed-ferret_465_600x450.jpg', desc: 'wat?!', link:'http://ferrets.com'}
    

  ];
  
});

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console