Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Refactor for Bower.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenrskelton committed May 31, 2014
1 parent f33bb93 commit 9dd17af
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 101 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bower_components
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,27 @@ Maintained by [Steven Skelton](https://github.com/stevenrskelton)
## Usage

1. Import Web Components' polyfill:
1. Add to your _bower.json_, then run ```bower update```

```json
"dependencies": {
"sortable-table": "sortable-table#~0.5.0"
}
```

2. Import Web Components' polyfill:

```html
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.3.0/platform.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.3.0/polymer.js"></script>
<script src="bower_components/platform/platform.js"></script>
```

2. Import Custom Element:
3. Import Custom Element:

```html
<link rel="import" href="src/sortable-table.html">
<link rel="import" href="bower_components/sortable-table/sortable-table.html">
```

3. Start using it!
4. Start using it!

```html
<sortable-table></sortable-table>
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sortable-table",
"version": "0.4.2",
"version": "0.5.0",
"homepage": "https://github.com/stevenrskelton/sortable-table",
"description": "Polymer Web Component that generates a sortable <table> from JSON",
"main": "src/sortable-table.html",
Expand All @@ -23,6 +23,6 @@
"grid"
],
"dependencies": {
"polymer": "Polymer/polymer#~0.2.4"
"polymer": "Polymer/polymer#>=0.3.1"
}
}
5 changes: 2 additions & 3 deletions examples/autogenerated-columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 800px }
</style>
Expand Down
5 changes: 2 additions & 3 deletions examples/columns-with-templates-that-are-templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 100% }
</style>
Expand Down
5 changes: 2 additions & 3 deletions examples/columns-with-templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 100% }
</style>
Expand Down
5 changes: 2 additions & 3 deletions examples/dynamic-columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 800px; }
</style>
Expand Down
1 change: 1 addition & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1>&lt;sortable-table&gt; Demos</h1>
<li><a href="large-dataset.html">Larger Datasets</a></li>
<li><a href="nested-tables.html">Nesting Tables in Cells</a></li>
<li><a href="paging.html">Paging, Top N Rows</a></li>
<!--<li><a href="fixed-height.html">Fixed Height / Number of Rows</a></li>-->
<li><a href="refreshing-data.html">Refreshing Data</a></li>
<li><a href="selected-rows.html">Selected Rows</a></li>
<li><a href="themes.html">Themes</a></li>
Expand Down
5 changes: 2 additions & 3 deletions examples/large-dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 100% }
</style>
Expand Down
67 changes: 33 additions & 34 deletions examples/nested-tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 100% }
</style>
Expand Down Expand Up @@ -90,37 +89,6 @@ <h2>Nested Tables and Hierarchical JSON</h2>
</template>

<script>
/* Group by day, for totals */
PolymerExpressions.prototype.cube = function(arr) {
var c = []
for(var i=0;i<arr.length;i++){
//d should be an array of unique days
var d = arr[i];
for(var j=0;j<d.length;j++){
//find day record in c
var s = null;
for(var k=0;k<c.length;k++){
if(c[k].day==d[j].day){
s = c[k];
break;
}
}
if(!s){
s = { day: d[j].day };
c.push(s);
}
//loop through properties and add them to s
//makes assumption that properties are the same, none missing
var o = d[j];
for (var key in o) {
if (o.hasOwnProperty(key) && key!='day') {
s[key] = (s[key] || 0) + o[key];
}
}
}
}
return c;
};

var fruits = [
{
Expand Down Expand Up @@ -184,6 +152,37 @@ <h2>Nested Tables and Hierarchical JSON</h2>
];

window.addEventListener('polymer-ready', function(){
/* Group by day, for totals */
PolymerExpressions.prototype.cube = function(arr) {
var c = []
for(var i=0;i<arr.length;i++){
//d should be an array of unique days
var d = arr[i];
for(var j=0;j<d.length;j++){
//find day record in c
var s = null;
for(var k=0;k<c.length;k++){
if(c[k].day==d[j].day){
s = c[k];
break;
}
}
if(!s){
s = { day: d[j].day };
c.push(s);
}
//loop through properties and add them to s
//makes assumption that properties are the same, none missing
var o = d[j];
for (var key in o) {
if (o.hasOwnProperty(key) && key!='day') {
s[key] = (s[key] || 0) + o[key];
}
}
}
}
return c;
};
var model = {
data: fruits,
columns: columns
Expand Down
5 changes: 2 additions & 3 deletions examples/paging.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 600px }
input, td:nth-of-type(2) { text-align: right }
Expand Down
17 changes: 0 additions & 17 deletions examples/platform.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/platform.js.map

This file was deleted.

13 changes: 0 additions & 13 deletions examples/polymer.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/polymer.js.map

This file was deleted.

5 changes: 2 additions & 3 deletions examples/refreshing-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 800px }
</style>
Expand Down
5 changes: 2 additions & 3 deletions examples/selected-rows.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
<style>
sortable-table { width: 800px; }
</style>
Expand Down
5 changes: 2 additions & 3 deletions examples/themes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="platform.js"></script>
<script src="polymer.js"></script>
<link rel="import" href="../src/sortable-table.html">
<script src="../../platform/platform.js"></script>
<link rel="import" href="../sortable-table.html">
</head>
<body unresolved>

Expand Down
3 changes: 3 additions & 0 deletions src/sortable-table.html → sortable-table.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<!--
https://github.com/stevenrskelton/sortable-table
-->

<script src="../polymer/polymer.js"></script>

<polymer-element name="sortable-table" attributes="data columns sortColumn sortDescending rowSelection multiSelect selected selectedRowStyle headerTemplate cellTemplate footerTemplate checkbox pageSize page">
<template>
<style>
Expand Down

0 comments on commit 9dd17af

Please sign in to comment.