Skip to content

Instantly share code, notes, and snippets.

@JeroenVinke
Created March 8, 2017 12:55
Show Gist options
  • Save JeroenVinke/861f98e06711e42caf4f1a40b9c2a22d to your computer and use it in GitHub Desktop.
Save JeroenVinke/861f98e06711e42caf4f1a40b9c2a22d to your computer and use it in GitHub Desktop.
Sortable: basic usage
<template>
<require from="./basic-use.css!css"></require>
<require from="aurelia-kendoui-bridge/sortable/sortable"></require>
<div id="example">
<div id="playlist">
<div id="playlist-title"><span>My Playlist</span></div>
<ul id="sortable-basic"
ak-sortable="k-cursor-offset.bind: {top: -10, left: -230};
k-hint.call: hint($event);
k-placeholder.call: placeholder($event);"
k-on-change.delegate="change()">
<li class="sortable" repeat.for="track of tracks">${track.title}<span>${track.duration}</span></li>
</ul>
</div>
</div>
</template>
export class BasicUse {
tracks = [
{ title: 'Papercut', duration: '3:04' },
{ title: 'One Step Closer', duration: '2:35' },
{ title: 'With You', duration: '3:23' },
{ title: 'Points of Authority', duration: '3:20' },
{ title: 'Crawling', duration: '3:29' },
{ title: 'Runaway', duration: '3:03' },
{ title: 'By Myself', duration: '3:09' },
{ title: 'In the End', duration: '3:36' },
{ title: 'A Place for My Head', duration: '3:04' },
{ title: 'Forgotten', duration: '3:14' },
{ title: 'Cure for the Itch', duration: '2:37' },
{ title: 'Pushing Me Away', duration: '3:11' }
]
hint(e) {
return $(e).clone().addClass('sortable-basic-use-hint');
}
placeholder(e) {
return $(e).clone().addClass('sortable-basic-use-placeholder').text('drop here');
}
change() {
console.log(this.tracks.map((t) => t.title));
}
}
#example {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#playlist {
margin: 30px auto;
width: 300px;
background-color: #f3f5f7;
border-radius: 4px;
border: 1px solid rgba(0,0,0,.1);
}
#playlist-title {
height: 80px;
background: url('https://demos.telerik.com/kendo-ui/content/web/sortable/playlist.png') no-repeat 50% 50% #ffffff;
border-radius: 4px 4px 0 0;
border-bottom: 1px solid rgba(0,0,0,.1);
}
#playlist-title span {
display: none;
}
#sortable-basic {
padding: 0;
margin: 0;
}
li.sortable {
list-style-type: none;
padding: 6px 8px;
margin: 0;
color: #666;
font-size: 1.2em;
cursor: move;
}
li.sortable:last-child {
border-bottom: 0;
border-radius: 0 0 4px 4px;
}
li.sortable span {
display: block;
float: right;
color: #666;
}
li.sortable:hover {
background-color: #dceffd;
}
li.sortable-basic-use-hint {
display: block;
width: 200px;
background-color: #52aef7;
color: #fff;
}
li.sortable-basic-use-hint:after {
content: "";
display: block;
width: 0;
height: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 6px solid #52aef7;
position: absolute;
left: 216px;
top: 8px;
}
li.sortable-basic-use-hint:last-child {
border-radius: 4px;
}
li.sortable-basic-use-hint span {
color: #fff;
}
li.sortable-basic-use-placeholder {
background-color: #dceffd;
color: #52aef7;
text-align: right;
}
<!doctype html>
<html>
<head>
<title>Aurelia KendoUI bridge</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.common.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.default.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.mobile.all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.4.0/bluebird.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.2.1/chroma.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/kendo.all.min.js"></script>
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script>
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-kendoui-bundles/1.0.0-beta.1.0.6/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-kendoui-bridge');
aurelia.start().then(a => a.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment