cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

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.

            
              <!-- Simple template for the ListView instantiation  -->
<div class="smallListIconTextTemplate" 
     data-win-control="WinJS.Binding.Template" 
     style="display: none">
    <div class="smallListIconTextItem">
        <span class="date-picker">
          <img src="#" 
             class="smallListIconTextItem-Image date-picker" 
             data-win-bind="src: picture"
             onerror="this.style.display='none'"/>
        </span>
        <div class="smallListIconTextItem-Detail">
            <h4 class="win-h4" data-win-bind="textContent: title"></h4>
            <h6 class="win-h6" data-win-bind="textContent: text"></h6>
            <h6 class="win-h6 counter" data-win-bind="innerText: counter"></h6>
        </div>
    </div>
</div>

<div class="listLayoutTopHeaderTemplate" data-win-control="WinJS.Binding.Template">
    <div class="listLayoutTopHeaderTemplateRoot">
        <div data-win-bind="innerHTML: title"></div>
    </div>
</div>

<!-- Elements used for header and footer elements for ListView -->
<div class="headerFooterPlaceholder">
    <div class="header">
        <span style="display: inline-block;">
          <h2 class="win-h2">Ordered ListView with Editing Items</h2>
          <p>
              <span>Total Items: </span>
              <span data-win-bind="textContent: data.length"></span>
          </p>
      </span>
      <span style="display: inline-block; float: right;">
        <button class="win-button" data-win-bind="onclick: eh.toggleStripes">
          Toggle Odd/Even
        </button>
        <button id="removeSelected" class="win-button" data-win-bind="onclick: eh.removeSelected">
           Remove 
        </button>
      </span>
    </div>
    <div class="footer">
        <div>
          <button class="win-button" 
                  data-win-bind="onclick: eh.backToTop">
            Back to Top
          </button>
        </div>
        <div class="status">
            <div>Loading more items </div>
            <progress class="win-progress-bar progress hide"></progress>
        </div>
    </div>
</div>

<div id="listView"
     class="listView stripes win-selectionstylefilled "
     data-win-control="WinJS.UI.ListView"
     data-win-options="{
            itemDataSource: Sample.ListView.data.dataSource,
            itemTemplate: select('.smallListIconTextTemplate'),
            header: select('.header'),
            footer: select('.footer'),
            onheadervisibilitychanged: Sample.ListView.eh.headerVisibility,
            onfootervisibilitychanged: Sample.ListView.eh.footerVisibility,
            layout: { type: WinJS.UI.ListLayout, groupHeaderPosition: 'top'},
            groupDataSource: Sample.ListView.data.groups.dataSource,
            groupHeaderTemplate: select('.listLayoutTopHeaderTemplate'),                        
            selectionMode: 'multi',
            tapBehavior: WinJS.UI.TapBehavior.toggleSelect
        }">
</div>
            
          
!
            
              /* Template for the items in the ListViews in this sample */       
.smallListIconTextItem
{
    width: 100%;
    height: 70px;
    padding: 5px;
    overflow: hidden;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
}

    .smallListIconTextItem img.smallListIconTextItem-Image 
    {
        width: 64px;
        height: 64px;
        margin: 5px;
        margin-right:20px;
    }

    .smallListIconTextItem .smallListIconTextItem-Detail
    {
        margin: 5px;
    }

   .listLayoutTopHeaderTemplateRoot, .gridLayoutLeftHeaderTemplateRoot {
        font-size: larger;
        margin-left: 16px;
    }
    
/* CSS applied to the ListViews in this sample */
#listView
{
    height: 100%;
}

.headerFooterPlaceholder {
    display: none;
}

.listView .header,
.listView .footer {
    height: 80px;
    padding: 10px;
    background-color: #333;
}

.listView .footer .progress.hide {
    display: none;
}

img.date-picker {
  display: none;
}

span.date-picker:after {
  font-family: FontAwesome;
  content: "\f03e";
  color: grey;
  font-size: 64px;
  display: inline-block;
  margin-top: 0em;
  margin-bottom: 0em;
  margin-right: 5px;
}

/* Override the background color for even/odd win-containers */
.listView.stripes .win-container.win-container-odd {
    background-color: #212;
}

.listView.stripes .win-container.win-container-even {
    background-color: #424;
}

.counter {
    font-size: 8pt;
    position: absolute;
    top: 0px;
    right: 5px;
    width: 20px;
    height: 20px;
    text-align: left;
}

            
          
!
            
               var itemArray = [
    { title: "Banana Blast", text: "Low-fat frozen yogurt", picture: "/images/fruits/60Banana.png" }
 ];

// For Example of loading
var itemArray2 = [
    { title: "Banana Blast Two", text: "Low-fat frozen yogurt", picture: "/images/fruits/60Banana.png" }, 
    { title: "Marvelous Mint", text: "Gelato", picture: "/images/fruits/60Mint.png" },
    { title: "Succulent Strawberry", text: "Sorbet", picture: "/images/fruits/60Strawberry.png" },
    { title: "Lavish Lemon Ice", text: "Sorbet", picture: "/images/fruits/60Lemon.png" },
    { title: "Creamy Orange", text: "Sorbet", picture: "/images/fruits/60Orange.png" },
    { title: "Very Vanilla", text: "Ice Cream", picture: "/images/fruits/60Vanilla.png" },
    { title: "Lavish Lemon Ice Two", text: "Sorbet", picture: "/images/fruits/60Lemon.png" }
  ];


function generateItems() {
  var tIndex = 0;
  itemArray.forEach(function(item){
    item.counter = tIndex++;
  });
  return itemArray;
};

var items = generateItems();
var data = new WinJS.Binding.List(items);

var groupedData = data.createGrouped(function (item) {
    return item.title.toUpperCase().charAt(0);
}, function (item) {
    return {
        title: item.title.toUpperCase().charAt(0)
    };
}, function (left, right) {
    return left.charCodeAt(0) - right.charCodeAt(0);
});

WinJS.Namespace.define("Sample.ListView", {
    generate: generateItems,
    data: groupedData,
    eh: {
        footerVisibility: WinJS.UI.eventHandler(function (ev) {
            var visible = ev.detail.visible;
            if (visible) {
                WinJS.Utilities.removeClass(Sample.ListView.progress, "hide");
                WinJS.UI.Animation.fadeIn(Sample.ListView.status);

                // Simulate XHR by just setting a timeout and updating the observable binding list     
                WinJS.Promise.timeout(100).then(function () {
                  var items = itemArray2;
                  items.forEach(function (item) {
                    Sample.ListView.data.push(item);
                  });
                });
              
            } else {
                WinJS.Utilities.addClass(Sample.ListView.progress, "hide");
            }
        }),
        toggleStripes: WinJS.UI.eventHandler(function (ev) {   
            WinJS.Utilities.toggleClass(Sample.ListView.listView, "stripes");         
        }),
        backToTop: WinJS.UI.eventHandler(function (ev) {
            Sample.ListView.listView.winControl.scrollPosition = 0;
        }),
        removeSelected: WinJS.UI.eventHandler(function (ev) {
            //Sample.ListView.listView.winControl.scrollPosition = 0;
          removeSelected();
        })
    }
});

// Remove the selected tile
function removeSelected() {
  // Get the control
  //var list2 = document.getElementById("listView").winControl;
  var list2 = Sample.ListView.listView.winControl;
  
  if (list2.selection.count() > 0) {
    list2.selection.getItems().done(function (items) {

      //Sort the selection to ensure its in index order
      items.sort(function CompareForSort(item1, item2) {
        var first = item1.index, second = item2.index;
        if (first === second) {
          return 0;
        } else if (first < second) {
          return -1;
        }
        else {
          return 1;
        }
      });

      //Work backwards as the removal will affect the indices of subsequent items
      for (var j = items.length - 1; j >= 0; j--) {
        // To remove the items, call splice on the list, passing in a count and no replacements
        data.splice(items[j].index, 1);
      }
      
    });
  }
}


// Cache ListView and Header elements
Sample.ListView.listView = document.querySelector(".listView");
Sample.ListView.header = document.querySelector(".header");
Sample.ListView.progress = document.querySelector(".footer .progress");
Sample.ListView.status = document.querySelector(".footer .status");

// Data bind header element and split pane element
WinJS.Binding.processAll(Sample.ListView.header, Sample.ListView).then(function () {
    return WinJS.Binding.processAll(Sample.ListView.splitPane, Sample.ListView);
}).then(function () {
    // Process UI to initialize WinJS controls 
    return WinJS.UI.processAll();
});

var msToTime = function(duration) {
  var milliseconds = parseInt((duration % 1000)/100);
  var seconds = parseInt((duration / 1000) % 60);
  var minutes = parseInt((duration / (1000*60)) % 60);
  var hours = parseInt((duration / (1000*60*60)) % 24);

  hours = (hours < 10) ? "0" + hours : hours;
  minutes = (minutes < 10) ? "0" + minutes : minutes;
  seconds = (seconds < 10) ? "0" + seconds : seconds;

  return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
};
            
          
!
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