Skip to content

Commit bc209f1

Browse files
author
Maxim
committed
autocomplete init
1 parent ca2c5ff commit bc209f1

19 files changed

+2927
-1
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.build
2+
#/resources
3+
/dist
4+
/lib
5+
/vendor
6+
/node_modules
7+
*.log
8+
.DS_Store
9+
.idea

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
# sf-module-autocomplete
1+
# sf-module-autocomplete
2+
3+
Autocomplite module
4+
5+
## Usage Example
6+
7+
## Local Development
8+
9+
### Installation
10+
11+
npm install -g gulp
12+
npm install
13+
14+
### Building
15+
16+
gulp build
17+
18+
19+
## License
20+
21+
Copyright (c) 2016 Yauheni Yasinau, Maxim Matveev and contributors. Released under an [MIT license](https://github.com/sfjs/sf-module-autocomplete/blob/master/LICENSE).

config/build.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var del = require('del'),
2+
gulp = require('gulp'),
3+
gutil = require('gulp-util'),
4+
header = require('gulp-header'),
5+
rename = require('gulp-rename'),
6+
uglify = require('gulp-uglify'),
7+
webpack = require('webpack'),
8+
sourcemaps = require('gulp-sourcemaps'),
9+
webpackConfig = require('./webpack.conf');
10+
11+
module.exports = function () {
12+
gulp.task('source', function (callback) {
13+
webpack(webpackConfig, function (err, stats) {
14+
var json = stats.toJson();
15+
(json.warnings || []).forEach(function (warning) {
16+
gutil.log(gutil.colors.yellow("[webpack] " + warning));
17+
});
18+
(json.errors || []).forEach(function (error) {
19+
gutil.log(gutil.colors.red("[webpack] " + error));
20+
});
21+
if (err) throw new gutil.PluginError('webpack', err);
22+
callback();
23+
});
24+
});
25+
};
26+

config/webpack.conf.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
var path = require('path');
2+
var pkg = require('../package.json');
3+
var webpack = require('webpack');
4+
5+
var BANNER =
6+
'Autocomplete module v.'+pkg.version+'\n' +
7+
'https://github.com/sfjs/sf-module-autocomplete/\n' +
8+
'Copyright (c) 2016, Alex Chepura, Yauheni Yasinau, Maxim Matveev, spiralscout.com';
9+
10+
var bannerPlugin = new webpack.BannerPlugin(BANNER);
11+
var uglifyJsPlugin = new webpack.optimize.UglifyJsPlugin({
12+
include: /\.min\.js$/,
13+
minimize: true,
14+
compress: {
15+
warnings: false
16+
}
17+
});
18+
19+
module.exports = {
20+
entry: {
21+
"sf.autocomplete": './src/index.js', // webpack workaround issue #300
22+
"sf.autocomplete.min": './src/index.js' // webpack workaround issue #300
23+
},
24+
output: {
25+
filename: '[name].js',
26+
libraryTarget: 'umd',
27+
path: path.resolve(__dirname, '..', 'resources/scripts/spiral/')
28+
},
29+
resolve: {
30+
alias: {
31+
'sf': path.resolve(__dirname, '..', 'node_modules/sf/src/sf')
32+
},
33+
extensions: ['', '.js']
34+
},
35+
resolveLoader: {
36+
root: path.resolve(__dirname, '..', 'node_modules')
37+
},
38+
module: {
39+
loaders: [
40+
{
41+
test: /\.js?$/,
42+
loader: 'babel?presets[]=es2015&plugins[]=transform-runtime',
43+
exclude: /node_modules/
44+
}
45+
],
46+
noParse: []
47+
},
48+
devtool: 'source-map',
49+
plugins: [bannerPlugin, uglifyJsPlugin],
50+
externals: {
51+
"sf": "sf"
52+
}
53+
};

example/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Autocomplete example</title>
6+
<link rel="stylesheet" href="sf.css"/>
7+
</head>
8+
<body>
9+
<div class="item-form">
10+
<input type="text" value="" data-key="" data-name="test" data-url="response.php" class="js-sf-autocomplete"/>
11+
</div>
12+
<script src="sf.min.js"></script>
13+
<script src="../resources/scripts/spiral/sf.autocomplete.js"></script>
14+
15+
</body>
16+
</html>

example/response.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?
2+
header('Content-type: application/json');
3+
4+
$response = array(
5+
'status' => 200,
6+
'suggestions' => array(
7+
'first' => 'first suggestion',
8+
'second' => 'second suggestion'
9+
)
10+
);
11+
12+
echo json_encode($response);
13+
14+
?>

0 commit comments

Comments
 (0)