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.

            
              <body ng-app="app" ng-controller="main">
  <header>
      <h1>Objects <span>( {{ items.length }} )</span></h1>
    </header>
  <main>    

    <div class="ctrls">
      
      <div class="filter">
        <span class="m m-search"></span>
        <input type="text" ng-model="searchies" ng-change="onQueryChange(searchies)" class="form-control" placeholder="Filter">
      </div>

      <div class="grid-toggle">
        <a ng-click="gridToggle = !gridToggle" ng-class="{ 'active' : gridToggle }">
          <span class="m m-squares"></span>
          <span class="m m-form"></span>
        </a>
      </div>
      
    </div>
    
  
    <div class="container">
      
      <ul class="grid" ng-class="{ 'grid-list' : gridToggle, 'grid-thumb' : !gridToggle }">
        <li class="grid-head">
          <ul>
            <li style="width:40%"><a ng-click="sort_by('name')">Name</a></li>
            <li style="width:30%"><a ng-click="sort_by('user.name')">User</a></li>
              <li style="width:15%"><a ng-click="sort_by('date')">Date</a></li>
            <li style="width:15%"></li>
          </ul>
        </li>
        <li class="grid-body animate-repeat" ng-repeat="item in pagedItems[currentPage - 1] | orderBy:sortingOrder:reverse" ng-class="{'last':$last}">
          
          <ul>
            <li>
              
              <span class="grid-icon m" ng-class="item.icon"></span>
              <span class="grid-title"><a href="#">{{ item.name }}</a></span>
            </li>
            
            <li>
              <span class="grid-user">
                <span class="grid-usericon" ng-style="{ 'background' : item.user.color }">{{ item.user.name }}</span>
                <span class="grid-username">Updated by {{ item.user.name }}</span>
              </span>
            </li>
            
            <li>
              <span class="grid-date">{{ item.date }}</span>
            </li>
            
            <li>
              <span class="grid-options"><a href="#"><span class="m m-ellipsis"></span></a></span>
            </li>
          </ul>
          
        </li>
        
        <li class="clear-fix"></li>
        
        <li class="pagination">
          <pager total-items="totalItems" items-per-page="itemsPerPage" ng-model="currentPage" max-size="maxSize" ng-change="pageChanged()"></pager>
          <p ng-if="itemsPerPage * currentPage < totalItems">
            Showing {{ itemsPerPage * currentPage - itemsPerPage + 1 }} - {{ itemsPerPage * currentPage }} of {{ totalItems }} total items
          </p>
          <p ng-if="itemsPerPage * currentPage >= totalItems">
            Showing {{ itemsPerPage * currentPage - itemsPerPage + 1 }} - {{ totalItems }} of {{ totalItems }} total items
          </p>
        </li>
      </ul>
      
    </div>
    
  </main>
  
  <footer>
    <p>Me playing with a mockup for a searchable collection of objects using angularjs.</p>
  </footer>
  
</body>

            
          
!
            
              @import "compass/css3";

@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,600,700);

$body: #38405e;
$bg: #f9fcfe;
$gray: #5d7592;
$shadow: #dde8f0;
$gray2: #476283;
$primary: #1bbbef;

.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;
  user-select: none; 
}
::-webkit-input-placeholder { color: $gray; }
:-moz-placeholder {  color: $gray; }
::-moz-placeholder { color: $gray; }
:-ms-input-placeholder { color: $gray; }

.m {
  font-size: 28px;
}

body {
  text-align: center;
  background: $bg;
  color: $body;
  font-size: 16px;
  font-family: 'Open Sans', sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

header {
  width: 100%;
  background: $body;
  padding: 3em 0;
  color: white;
  h1 {
    font-weight: 300;
    font-size: 36px;
    margin: 0.75em 0;
    span {
      font-size: 90%;
      color: $primary;
    }
  }
}

main {
  padding: 1.5em 0 0;
}

footer, main {
  max-width: 960px;
  margin: 0 auto;
  &:after {
    content: '';
    display: block;
    clear: both;
  }
}
footer {
  padding: 2em 0;
  p {
    color: $gray;
    font-size: 14px;
  }
}

.ctrls {
  margin-bottom: 1em;
  &:after {
    content: '';
    clear: both;
    display: block;
  }
}

.filter {
  float: left;
  width: 75%;
  padding-left: 2.5em;
  .m {
    color: $gray;
    position: absolute;
    margin-left: -1.25em;
  }
  input {
    width: 100%;
    vertical-align: top;
    height: 2em;
    border: none;
    background: $bg;
    font-size: 16px;
    font-weight: 300;
    color: $gray;
    outline: none;
    padding: 0 0.5em;
  } 
}
.grid-toggle {
  cursor: pointer;
  @extend .no-select;
  float: right;
  a {
    span { color: $gray; }
    span:first-child { color: $body; margin-right: 12px; }
    &.active {
      span:first-child { color: $gray; }
      span:last-child { color: $body; }
    }
  }
}


.btn {
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 600;
  color: $gray;
}

.container {
  
}

ul.grid {
  .grid-body ul {
    li {
      span {
        display: inline-block;
        line-height: normal;
        vertical-align: middle;
        &.grid-icon {
          color: $gray2;
        }
        &.grid-title a {
          font-size: 16px;
          font-weight: 500;
          color: $body;
          text-decoration: none;
          &:hover { text-decoration: underline; }
        }
        &.grid-usericon {
          &:first-letter {
            color: white;
            font-size: 16px;
          }
          margin-right: 12px;
          font-size: 0;
          width: 36px;
          height: 36px;
          line-height: 36px;
          text-align: center;
          background: $primary;
          @include border-radius(100px);
        }
        &.grid-date, &.grid-user {
          color: $gray;
          font-size: 14px;
        }
        a .m {
          color: $gray;
        }
      }
    }
  }
}

ul.grid.grid-thumb {
  &:after {
    content:'';
    display: block;
    clear: both;
  }
  .grid-head { display: none; }
  .grid-body {
    width: 50%;
    float: left;
    @include box-sizing(border-box);
    margin-bottom: 2em;
    &:nth-child(even) { padding-right: 1em; }
    &:nth-child(odd) { padding-left: 1em; }
    ul {
      @include box-sizing(border-box);
      background: white;
      border: 1px solid $shadow;
      padding: 1em 1.5em .75em;
      @include border-radius(5px);
      float: left;
      width: 100%;
      &:after {
        content:'';
        display: block;
        clear: both;
      }
      li {
        position: relative;
        span {
          &.grid-icon {
            display: block;
            font-size: 56px;
            margin: 0 0 12px;
          }
          &.grid-title {
            display: block;
            margin-bottom: 1em;
          }
          &.grid-user {
            .grid-usericon {
              position: absolute;
              left: 0;
              bottom: -37px;
            }
            margin-bottom: 2px;
          }
          &.grid-date {
            display: block;
          }
          &.grid-options {
            float: right;
          }
        }
      }
    }
  }
}

ul.grid.grid-list {
  background: white;
  border: 1px solid $shadow;
  padding: 0 2em;
  @include border-radius(5px);
  li.grid-body {
    border-bottom: 1px solid $shadow;
    &:last-child, &.last { border-bottom: none; }
  }
  .grid-head ul {
    &:after {
      content:'';
      display: block;
      clear: both;
    }
    li {
      @extend .no-select;
      font-size: 16px;
      border: none;
      text-align: left;
      padding: 2em 0 1em;
      float: left;
      a {
        cursor: pointer;
        color: $primary;
        font-weight: 600;
        &:hover {
          text-decoration: underline;
        }
      }
    }
  }
  .grid-body ul {
    &:after {
      content:'';
      display: block;
      clear: both;
    }
    li {
      border: none;
      text-align: left;
      height: 5em;
      line-height: 5em;
      padding: 0;
      float: left;
      &:first-child { text-align: left; width: 40%; }
      &:nth-child(2) { width: 30%; }
      &:nth-child(3) { width: 15%; }
      &:last-child { text-align: right; width: 15%; }
      span {
        &.grid-icon {
          margin-right: 0.5em;
        }
        &.grid-username {
          width: 100px;
        }
      }
    }
  }
}
li.clear-fix {
  display: block;
  clear: both;
}
li.pagination {
  padding: 1em 0 2em;
  p {
    font-size: 14px;
  }
  ul.pager {
    margin: 2em 0;
    li {
      display: inline;
      &:first-child { margin-right: 1em; }
      a {
        color: $primary;
        text-decoration: none;
        padding: 0.5em 1.5em;
        border: 1px solid $primary;
        @include border-radius(100px);
      }
    }
  } 
}
// Animations
.animate-repeat {
  list-style:none;
  box-sizing:border-box;
  overflow: hidden;
}

.animate-repeat.ng-move,
.animate-repeat.ng-enter,
.animate-repeat.ng-leave {
  -webkit-transition:all ease-in-out 0.4s;
  transition:all ease-in-out 0.4s;
}

.animate-repeat.ng-leave.ng-leave-active,
.animate-repeat.ng-move,
.animate-repeat.ng-enter {
  opacity:0;
}

.animate-repeat.ng-leave,
.animate-repeat.ng-move.ng-move-active,
.animate-repeat.ng-enter.ng-enter-active {
  opacity:1;
}
.grid-thumb {
  .animate-repeat.ng-move,
  .animate-repeat.ng-enter,
  .animate-repeat.ng-leave {
    -webkit-transition:none;
    transition:none;
  }
}
.grid-list {
  .animate-repeat {
    line-height:5em;
  }
  .animate-repeat.ng-leave.ng-leave-active,
  .animate-repeat.ng-move,
  .animate-repeat.ng-enter {
    height:0;
  }
  .animate-repeat.ng-leave,
  .animate-repeat.ng-move.ng-move-active,
  .animate-repeat.ng-enter.ng-enter-active {
    height:5em;
  }
}
            
          
!
            
              angular.module('app', ['ui.bootstrap', 'ngAnimate'])
.factory('sortable', ['$filter', '$rootScope', function($filter, $rootScope){

  return function (scope, data, itemsPerPage, initSortingOrder) {

    
    scope.sortingOrder = initSortingOrder;
    scope.reverse = false;
    scope.filteredItems = [];
    scope.groupedItems = [];
    scope.itemsPerPage = itemsPerPage;
    scope.pagedItems = [];
    scope.currentPage = 1;
    scope.items = data;
    scope.maxSize = 5;

    var searchMatch = function (haystack, needle) {
          if (!needle) {
              return true;
          }
          return haystack.toLowerCase().indexOf(needle.toLowerCase()) !== -1;
      };


      // init the filtered items
      scope.search = function () {

          scope.filteredItems = $filter('filter')(scope.items, $rootScope.query);

          // take care of the sorting order
        if (scope.sortingOrder !== '') {
            scope.filteredItems = $filter('orderBy')(scope.filteredItems, scope.sortingOrder, scope.reverse);
        }

          scope.currentPage = 1;

          // now group by pages
          scope.groupToPages();

          // reset the total items for the pagination buttons
          scope.totalItems = scope.filteredItems.length;
      };
      

      // calculate page in place
      scope.groupToPages = function () {
          scope.pagedItems = [];
          
          for (var i = 0; i < scope.filteredItems.length; i++) {
              if (i % scope.itemsPerPage === 0) {
                  scope.pagedItems[Math.floor(i / scope.itemsPerPage)] = [ scope.filteredItems[i] ];
              } else {
                  scope.pagedItems[Math.floor(i / scope.itemsPerPage)].push(scope.filteredItems[i]);
              }
          }
      };
      

      scope.range = function (start, end) {
          var ret = [];
          if (!end) {
              end = start;
              start = 0;
          }
          for (var i = start; i < end; i++) {
              ret.push(i);
          }
          return ret;
      };


      // functions have been described process the data for display
      scope.search();


      // change sorting order
      scope.sort_by = function(newSortingOrder) {
          if (scope.sortingOrder == newSortingOrder)
              scope.reverse = !scope.reverse;

          scope.sortingOrder = newSortingOrder;

          // call search again to make sort affect whole query
          scope.search();
      };

      scope.sort_by(initSortingOrder);
      scope.totalItems = scope.filteredItems.length;
  }

}])
  .controller('main', [ '$scope', '$rootScope', 'sortable', function($scope, $rootScope, sortable) {
    
    $rootScope.query = '';
    
    $scope.gridToggle = true;

    $scope.onQueryChange = function(val){
       $rootScope.query = val;
       $scope.search();
    };
    
    var items = [
      { 'icon' : 'm-munkey',  'name' : 'A Munkey Page',          'date' : 'Yesterday at Noon', 'user' : { 'name' : 'Munkey',  'color' : '#07D5E5'} },
      { 'icon' : 'm-bug',     'name' : 'Mobile Splash Page',     'date' : 'Yesterday at 4:30pm', 'user' : { 'name' : 'Munkey',  'color' : '#07D5E5'} },
      { 'icon' : 'm-photo',   'name' : 'Some Other Site',        'date' : 'Today at 3:35am', 'user' : { 'name' : 'Someone', 'color' : '#456183'} },
      { 'icon' : 'm-desktop', 'name' : 'Jerry\'s Blog',          'date' : 'Thursday at 7:15pm', 'user' : { 'name' : 'Jerry',   'color' : '#4677A7'} },
      { 'icon' : 'm-form',    'name' : 'Ape\'s Capture Form',    'date' : 'Today at Noon', 'user' : { 'name' : 'Ape',     'color' : '#09ABC5'} },
      { 'icon' : 'm-phone',   'name' : 'Some Mobile Site',       'date' : 'Thursday at 1:27pm', 'user' : { 'name' : 'Someone', 'color' : '#456183'} },
      { 'icon' : 'm-bell',    'name' : 'Fish\'s Wordpress Site', 'date' : 'Yesterday at Noon', 'user' : { 'name' : 'Fish',    'color' : '#1CB7BB'} },
      { 'icon' : 'm-group',   'name' : 'Kitty Kat Kapture Form', 'date' : 'Wednesday at 7:15pm', 'user' : { 'name' : 'Kitty',   'color' : '#1D9D9D'} }
    ];
    
    sortable($scope, items, 6, 'updated_at');
    
  }]);
            
          
!
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