Skip to content

Commit 6217cfb

Browse files
author
Marty Wallace
committed
Minified.
1 parent 34b7773 commit 6217cfb

7 files changed

+50
-19
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
bower_components
2+
node_modules
23
.DS_Store

bower.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"version": "1.0.0",
44
"dependencies": {
55
"vue": "^1.0.26"
6-
}
6+
},
7+
"main": "dist/vue-keyboard.js"
78
}

demo/basic.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<p>{{ input }}</p>
1010

1111
<script src="../bower_components/vue/dist/vue.min.js"></script>
12-
<script src="../src/vue-keyboard.js"></script>
12+
<script src="../dist/vue-keyboard.js"></script>
1313

1414
<script>
1515
var app = new Vue({

dist/vue-keyboard.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
const gulp = require('gulp');
4+
const babel = require('gulp-babel');
5+
const uglify = require('gulp-uglify');
6+
7+
gulp.task('js', () => {
8+
return gulp.src('./src/vue-keyboard.js')
9+
.pipe(babel({ presets: ['es2015'] }))
10+
.pipe(uglify())
11+
.pipe(gulp.dest('./dist'));
12+
});
13+
14+
gulp.task('watch', () => {
15+
gulp.watch('./src/vue-keyboard.js', ['js']);
16+
});
17+
18+
gulp.task('default', ['js', 'watch']);

package.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "vue-keyboard",
3+
"version": "1.0.0",
4+
"devDependencies": {
5+
"gulp": "^3.9.1",
6+
"gulp-uglify": "1.5.*",
7+
"gulp-babel": "^6.1.2",
8+
"babel-preset-es2015": "^6.9.0"
9+
}
10+
}

src/vue-keyboard.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
(function() {
2-
window.Keyboard = Vue.component('keyboard', Vue.extend({
1+
(() => {
2+
window.VueKeyboard = Vue.component('keyboard', Vue.extend({
33
template: '<div class="keyboard"><div v-for="row in renderChars()"><button v-for="char in row" :class="char.class" @click="char.action">{{ char.value }}</button></div></div>',
44

55
props: {
@@ -14,20 +14,20 @@
1414
},
1515

1616
methods: {
17-
renderChars: function() {
18-
var lines = this.chars.split('|');
17+
renderChars() {
18+
let lines = this.chars.split('|');
1919

20-
return lines.map(function(chars) {
21-
var stream = chars.split('');
22-
var buttons = [];
23-
var token = null;
20+
return lines.map((chars) => {
21+
let stream = chars.split('');
22+
let buttons = [];
23+
let token = null;
2424

25-
stream.forEach(function(char) {
25+
stream.forEach((char) => {
2626
if (char === '{') {
2727
token = '';
2828
} else if (char === '}') {
29-
var command = (/(\w+):(\w+)/g).exec(token);
30-
var action = null;
29+
let command = (/(\w+):(\w+)/g).exec(token);
30+
let action = null;
3131

3232
if (this.hasOwnProperty(command[2])) {
3333
action = this[command[2]].bind(this);
@@ -52,25 +52,25 @@
5252
});
5353
}
5454
}
55-
}, this);
55+
});
5656

5757
return buttons;
58-
}, this);
58+
});
5959
},
6060

61-
append: function(char) {
61+
append(char) {
6262
this.value += char;
6363
},
6464

65-
backspace: function() {
65+
backspace() {
6666
this.value = this.value.slice(0, this.value.length - 1);
6767
},
6868

69-
space: function() {
69+
space() {
7070
this.value += ' ';
7171
},
7272

73-
clear: function() {
73+
clear() {
7474
this.value = '';
7575
}
7676
}

0 commit comments

Comments
 (0)