<head>
<meta charset="utf-8">
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<base href="https://polygit.org/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link href="polymer/polymer.html" rel="import">
<link href="paper-card/paper-card.html" rel="import">
<link href="paper-item/paper-item.html" rel="import">
<link href="paper-button/paper-button.html" rel="import">
<link href="paper-checkbox/paper-checkbox.html" rel="import">
<link href="iron-list/iron-list.html" rel="import">
</head>
<body>
<dom-module id="x-element">
<template>
<style>
paper-card {
display: block;
}
iron-list {
height: 100%;
}
paper-item {
padding: 0;
}
.flex-horizontal-with-ratios {
@apply(--layout-horizontal);
}
.flexchild {
@apply(--layout-flex);
}
.info-head > * {
font-weight: 700;
padding: 16px 0;
}
.info-head {
border-bottom: 1px solid #7f7f7f;
}
.info-item {
border-bottom: 1px solid #d4d4d4;
padding: 16px 0;
min-height: inherit;
}
</style>
<paper-card heading="Users">
<div hidden$="[[!hasUsers]]" class="card-options">
<paper-button hidden$="[[!showDeleteOption]]" on-tap="_deleteSelected" raised>Delete</paper-button>
</div>
<div class="card-content">
<div class="flex-horizontal-with-ratios info-head">
<div class="flexchild">
Name
</div>
<div class="flexchild">
Gender
</div>
</div>
<iron-list items="[[users]]" as="user" selected-items="{{selectedUsers}}" multi-selection>
<template>
<paper-item class="info-item flex-horizontal-with-ratios">
<div class="flexchild">
<paper-checkbox on-tap="_selectItem"></paper-checkbox> [[user.name]]
</div>
<div class="flexchild">
[[user.gender]]
</div>
</paper-item>
</template>
</iron-list>
</div>
</paper-card>
</template>
<script>
(function(){
Polymer({
is: "x-element",
properties: {
users: {
type: Array,
value: [{
name: 'John Doe',
gender: 'male'
}, {
name: 'Jane Doe',
gender: 'female'
}, {
name: 'Jack Doe',
gender: 'male'
}]
},
hasUsers: {
type: Boolean,
value: false
},
showDeleteOption: {
type: Boolean,
value: false
}
},
observers: [
'_listsChanged(users.*, selectedUsers.*)'
],
_listsChanged: function(users, selectedUsers) {
this.set('showDeleteOption', selectedUsers.base.length > 0);
this.set('hasUsers', users.base.length > 0);
},
_selectItem: function(e) {
var index = e.model.index,
model = this.users[index],
exists = this.selectedUsers.indexOf(model) != -1;
if (exists) {
this.querySelector('iron-list').deselectItem(model);
} else {
this.querySelector('iron-list').selectItem(model);
}
console.log(this.selectedUsers);
},
_deleteSelected: function(e) {
this.selectedUsers.forEach(function(user) {
var index = this.users.indexOf(user);
;
if (index != -1) {
this.splice('users', index, 1);
}
}, this);
this.querySelector('iron-list').clearSelection();
console.log(this.selectedUsers);
}
});
})();
</script>
</dom-module>
<x-element></x-element>
</body>
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |