cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console