├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── build
├── build.js
├── check-versions.js
├── dev-client.js
├── dev-server.js
├── utils.js
├── webpack.base.conf.js
├── webpack.build.conf.js
└── webpack.dev.conf.js
├── config
├── dev.env.js
├── index.js
├── prod.env.js
└── test.env.js
├── demo
├── index.html
├── src
│ ├── App.vue
│ ├── main.js
│ └── sass
│ │ ├── _actions.scss
│ │ ├── app.scss
│ │ └── dataTables.bootstrap-fa.scss
└── static
│ └── users.json
├── package.json
├── src
├── components
│ ├── DataTable.vue
│ ├── Filter.vue
│ ├── PerPage.vue
│ └── Search.vue
├── main.js
├── options.js
├── plugin.js
└── util.js
└── test
├── e2e
├── custom-assertions
│ └── elementCount.js
├── nightwatch.conf.js
├── runner.js
└── specs
│ └── test.js
└── unit
├── .eslintrc
├── index.js
├── karma.conf.js
└── specs
└── Hello.spec.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-2"],
3 | "plugins": ["transform-runtime"],
4 | "comments": false
5 | }
6 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | build/*.js
2 | config/*.js
3 | lib/*.js
4 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parser: 'babel-eslint',
4 | extends: 'vue',
5 | 'rules': {
6 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | lib/
3 | .DS_Store
4 | npm-debug.log
5 | test/unit/coverage
6 | test/e2e/reports
7 | selenium-debug.log
8 | yarn.lock
9 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | build/
3 | config/
4 | demo/
5 | src/
6 | test/
7 | .babelrc
8 | .editorconfig
9 | .gitignore
10 | .eslintignore
11 | .eslintrc.js
12 | .DS_Store
13 | yarn.lock
14 | npm-debug.log
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Cretu Eusebiu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-datatables
2 |
3 | > A Vue 2.0 component for [DataTables](https://datatables.net) [WIP].
4 |
5 | ## Installation
6 |
7 | ``` bash
8 | npm install --save vue-datatables jquery datatables.net-bs datatables.net-responsive-bs
9 | ```
10 |
11 | For Webpack, add the following loader:
12 |
13 | ```js
14 | {
15 | test: /datatables\.net.*/,
16 | loader: 'imports?define=>false'
17 | }
18 | ```
19 |
20 | ## Usage
21 |
22 | ```
23 | import Vue from 'vue'
24 | import $ from 'jquery'
25 | require('datatables.net-bs')(window, $)
26 | // import VueResource from 'vue-resource'
27 | import VueDataTables from 'vue-datatables'
28 |
29 | import App from './App.vue'
30 |
31 | // Vue.use(VueResource)
32 | Vue.use(VueDataTables)
33 |
34 | new Vue({
35 | el: '#app',
36 | render: h => h(App)
37 | })
38 | ```
39 |
40 | See [demo/src/App.vue](demo/src/App.vue).
41 |
--------------------------------------------------------------------------------
/build/build.js:
--------------------------------------------------------------------------------
1 | // https://github.com/shelljs/shelljs
2 | require('./check-versions')()
3 | require('shelljs/global')
4 | env.NODE_ENV = 'production'
5 |
6 | var path = require('path')
7 | var config = require('../config')
8 | var ora = require('ora')
9 | var webpack = require('webpack')
10 | var webpackConfig = require('./webpack.demo.conf')
11 |
12 | var spinner = ora('building for production...')
13 | spinner.start()
14 |
15 | var assetsPath = path.join(config.demo.assetsRoot, config.demo.assetsSubDirectory)
16 | rm('-rf', assetsPath)
17 | mkdir('-p', assetsPath)
18 | // cp('-R', 'static/*', assetsPath)
19 |
20 | webpack(webpackConfig, function (err, stats) {
21 | spinner.stop()
22 | if (err) throw err
23 | process.stdout.write(stats.toString({
24 | colors: true,
25 | modules: false,
26 | children: false,
27 | chunks: false,
28 | chunkModules: false
29 | }) + '\n')
30 | })
31 |
--------------------------------------------------------------------------------
/build/check-versions.js:
--------------------------------------------------------------------------------
1 | var semver = require('semver')
2 | var chalk = require('chalk')
3 | var packageConfig = require('../package.json')
4 | var exec = function (cmd) {
5 | return require('child_process')
6 | .execSync(cmd).toString().trim()
7 | }
8 |
9 | var versionRequirements = [
10 | {
11 | name: 'node',
12 | currentVersion: semver.clean(process.version),
13 | versionRequirement: packageConfig.engines.node
14 | },
15 | {
16 | name: 'npm',
17 | currentVersion: exec('npm --version'),
18 | versionRequirement: packageConfig.engines.npm
19 | }
20 | ]
21 |
22 | module.exports = function () {
23 | var warnings = []
24 | for (var i = 0; i < versionRequirements.length; i++) {
25 | var mod = versionRequirements[i]
26 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
27 | warnings.push(mod.name + ': ' +
28 | chalk.red(mod.currentVersion) + ' should be ' +
29 | chalk.green(mod.versionRequirement)
30 | )
31 | }
32 | }
33 |
34 | if (warnings.length) {
35 | console.log('')
36 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
37 | console.log()
38 | for (var i = 0; i < warnings.length; i++) {
39 | var warning = warnings[i]
40 | console.log(' ' + warning)
41 | }
42 | console.log()
43 | process.exit(1)
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/build/dev-client.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | require('eventsource-polyfill')
3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4 |
5 | hotClient.subscribe(function (event) {
6 | if (event.action === 'reload') {
7 | window.location.reload()
8 | }
9 | })
10 |
--------------------------------------------------------------------------------
/build/dev-server.js:
--------------------------------------------------------------------------------
1 | require('./check-versions')()
2 | var config = require('../config')
3 | if (!process.env.NODE_ENV) process.env.NODE_ENV = config.dev.env
4 | var path = require('path')
5 | var express = require('express')
6 | var webpack = require('webpack')
7 | var opn = require('opn')
8 | var proxyMiddleware = require('http-proxy-middleware')
9 | var webpackConfig = process.env.NODE_ENV === 'testing'
10 | ? require('./webpack.demo.conf')
11 | : require('./webpack.dev.conf')
12 |
13 | // default port where dev server listens for incoming traffic
14 | var port = process.env.PORT || config.dev.port
15 | // Define HTTP proxies to your custom API backend
16 | // https://github.com/chimurai/http-proxy-middleware
17 | var proxyTable = config.dev.proxyTable
18 |
19 | var app = express()
20 | var compiler = webpack(webpackConfig)
21 |
22 | var devMiddleware = require('webpack-dev-middleware')(compiler, {
23 | publicPath: webpackConfig.output.publicPath,
24 | stats: {
25 | colors: true,
26 | chunks: false
27 | }
28 | })
29 |
30 | var hotMiddleware = require('webpack-hot-middleware')(compiler)
31 | // force page reload when html-webpack-plugin template changes
32 | compiler.plugin('compilation', function (compilation) {
33 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
34 | hotMiddleware.publish({ action: 'reload' })
35 | cb()
36 | })
37 | })
38 |
39 | // proxy api requests
40 | Object.keys(proxyTable).forEach(function (context) {
41 | var options = proxyTable[context]
42 | if (typeof options === 'string') {
43 | options = { target: options }
44 | }
45 | app.use(proxyMiddleware(context, options))
46 | })
47 |
48 | // handle fallback for HTML5 history API
49 | app.use(require('connect-history-api-fallback')())
50 |
51 | // serve webpack bundle output
52 | app.use(devMiddleware)
53 |
54 | // enable hot-reload and state-preserving
55 | // compilation error display
56 | app.use(hotMiddleware)
57 |
58 | // serve pure static assets
59 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
60 | app.use(staticPath, express.static('./demo/static'))
61 |
62 | module.exports = app.listen(port, function (err) {
63 | if (err) {
64 | console.log(err)
65 | return
66 | }
67 | var uri = 'http://localhost:' + port
68 | console.log('Listening at ' + uri + '\n')
69 | opn(uri)
70 | })
71 |
--------------------------------------------------------------------------------
/build/utils.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var config = require('../config')
3 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
4 |
5 | exports.assetsPath = function (_path) {
6 | var assetsSubDirectory = process.env.NODE_ENV === 'production'
7 | ? config.build.assetsSubDirectory
8 | : config.dev.assetsSubDirectory
9 | return path.posix.join(assetsSubDirectory, _path)
10 | }
11 |
12 | exports.cssLoaders = function (options) {
13 | options = options || {}
14 | // generate loader string to be used with extract text plugin
15 | function generateLoaders (loaders) {
16 | var sourceLoader = loaders.map(function (loader) {
17 | var extraParamChar
18 | if (/\?/.test(loader)) {
19 | loader = loader.replace(/\?/, '-loader?')
20 | extraParamChar = '&'
21 | } else {
22 | loader = loader + '-loader'
23 | extraParamChar = '?'
24 | }
25 | return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
26 | }).join('!')
27 |
28 | // Extract CSS when that option is specified
29 | // (which is the case during production build)
30 | if (options.extract) {
31 | return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
32 | } else {
33 | return ['vue-style-loader', sourceLoader].join('!')
34 | }
35 | }
36 |
37 | // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
38 | return {
39 | css: generateLoaders(['css']),
40 | postcss: generateLoaders(['css']),
41 | less: generateLoaders(['css', 'less']),
42 | sass: generateLoaders(['css', 'sass?indentedSyntax']),
43 | scss: generateLoaders(['css', 'sass']),
44 | stylus: generateLoaders(['css', 'stylus']),
45 | styl: generateLoaders(['css', 'stylus'])
46 | }
47 | }
48 |
49 | // Generate loaders for standalone style files (outside of .vue)
50 | exports.styleLoaders = function (options) {
51 | var output = []
52 | var loaders = exports.cssLoaders(options)
53 | for (var extension in loaders) {
54 | var loader = loaders[extension]
55 | output.push({
56 | test: new RegExp('\\.' + extension + '$'),
57 | loader: loader
58 | })
59 | }
60 | return output
61 | }
62 |
--------------------------------------------------------------------------------
/build/webpack.base.conf.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var config = require('../config')
3 | var utils = require('./utils')
4 | var projectRoot = path.resolve(__dirname, '../')
5 |
6 | var env = process.env.NODE_ENV
7 | // check env & config/index.js to decide weither to enable CSS Sourcemaps for the
8 | // various preprocessor loaders added to vue-loader at the end of this file
9 | var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
10 | var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
11 | var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
12 |
13 | module.exports = {
14 | resolve: {
15 | extensions: ['', '.js', '.vue'],
16 | fallback: [path.join(__dirname, '../node_modules')]
17 | },
18 | resolveLoader: {
19 | fallback: [path.join(__dirname, '../node_modules')]
20 | },
21 | module: {
22 | preLoaders: [
23 | {
24 | test: /\.vue$/,
25 | loader: 'eslint',
26 | include: projectRoot,
27 | exclude: /node_modules/
28 | },
29 | {
30 | test: /\.js$/,
31 | loader: 'eslint',
32 | include: projectRoot,
33 | exclude: /node_modules/
34 | }
35 | ],
36 | loaders: [
37 | {
38 | test: /\.vue$/,
39 | loader: 'vue'
40 | },
41 | {
42 | test: /\.js$/,
43 | loader: 'babel',
44 | include: projectRoot,
45 | exclude: /node_modules/
46 | },
47 | {
48 | test: /\.json$/,
49 | loader: 'json'
50 | },
51 | {
52 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
53 | loader: 'url',
54 | query: {
55 | limit: 10000,
56 | name: utils.assetsPath('img/[name].[hash:7].[ext]')
57 | }
58 | },
59 | {
60 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
61 | loader: 'url',
62 | query: {
63 | limit: 10000,
64 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
65 | }
66 | },
67 | {
68 | test: /datatables\.net.*/,
69 | loader: 'imports?define=>false'
70 | }
71 | ]
72 | },
73 | eslint: {
74 | formatter: require('eslint-friendly-formatter')
75 | },
76 | vue: {
77 | loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
78 | postcss: [
79 | require('autoprefixer')({
80 | browsers: ['last 2 versions']
81 | })
82 | ]
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/build/webpack.build.conf.js:
--------------------------------------------------------------------------------
1 | const webpack = require('webpack')
2 | const config = require('../config')
3 | var merge = require('webpack-merge')
4 | const baseWebpackConfig = require('./webpack.base.conf')
5 |
6 | var webpackConfig = merge(baseWebpackConfig, {
7 | entry: {
8 | lib: './src/main.js'
9 | },
10 | output: {
11 | path: config.bundle.assetsRoot,
12 | publicPath: config.bundle.assetsPublicPath,
13 | filename: 'vue-datatables.js',
14 | libraryTarget: 'umd'
15 | },
16 | externals: {
17 | vue: 'Vue',
18 | jquery: 'jQuery'
19 | },
20 | devtool: config.bundle.productionSourceMap ? '#source-map' : false
21 | })
22 |
23 | webpackConfig.plugins = (webpackConfig.plugins || []).concat([
24 | new webpack.DefinePlugin({
25 | 'process.env': {
26 | NODE_ENV: '"production"'
27 | }
28 | }),
29 | new webpack.optimize.UglifyJsPlugin({
30 | compress: { warnings: false }
31 | }),
32 | new webpack.optimize.OccurenceOrderPlugin()
33 | ])
34 |
35 | module.exports = webpackConfig
36 |
--------------------------------------------------------------------------------
/build/webpack.dev.conf.js:
--------------------------------------------------------------------------------
1 | var config = require('../config')
2 | var webpack = require('webpack')
3 | var merge = require('webpack-merge')
4 | var utils = require('./utils')
5 | var baseWebpackConfig = require('./webpack.base.conf')
6 | var HtmlWebpackPlugin = require('html-webpack-plugin')
7 |
8 | baseWebpackConfig.entry = {
9 | app: './demo/src/main.js'
10 | }
11 |
12 | // add hot-reload related code to entry chunks
13 | Object.keys(baseWebpackConfig.entry).forEach(function (name) {
14 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
15 | })
16 |
17 | module.exports = merge(baseWebpackConfig, {
18 | output: {
19 | path: config.build.assetsRoot,
20 | publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
21 | filename: '[name].js'
22 | },
23 | module: {
24 | loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
25 | },
26 | // eval-source-map is faster for development
27 | devtool: '#eval-source-map',
28 | plugins: [
29 | new webpack.DefinePlugin({
30 | 'process.env': config.dev.env
31 | }),
32 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
33 | new webpack.optimize.OccurenceOrderPlugin(),
34 | new webpack.HotModuleReplacementPlugin(),
35 | new webpack.NoErrorsPlugin(),
36 | // https://github.com/ampedandwired/html-webpack-plugin
37 | new HtmlWebpackPlugin({
38 | filename: 'index.html',
39 | template: 'demo/index.html',
40 | inject: true
41 | })
42 | ]
43 | })
44 |
--------------------------------------------------------------------------------
/config/dev.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var prodEnv = require('./prod.env')
3 |
4 | module.exports = merge(prodEnv, {
5 | NODE_ENV: '"development"'
6 | })
7 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | // see http://vuejs-templates.github.io/webpack for documentation.
2 | var path = require('path')
3 |
4 | module.exports = {
5 | build: {
6 | env: require('./prod.env'),
7 | index: path.resolve(__dirname, '../dist/index.html'),
8 | assetsRoot: path.resolve(__dirname, '../dist'),
9 | assetsSubDirectory: 'static',
10 | assetsPublicPath: '/',
11 | productionSourceMap: true,
12 | // Gzip off by default as many popular static hosts such as
13 | // Surge or Netlify already gzip all static assets for you.
14 | // Before setting to `true`, make sure to:
15 | // npm install --save-dev compression-webpack-plugin
16 | productionGzip: false,
17 | productionGzipExtensions: ['js', 'css']
18 | },
19 | bundle: {
20 | assetsRoot: path.resolve(__dirname, '../lib'),
21 | assetsPublicPath: '/',
22 | productionSourceMap: true
23 | },
24 | demo: {
25 | index: path.resolve(__dirname, '../gh-pages/index.html'),
26 | assetsRoot: path.resolve(__dirname, '../gh-pages'),
27 | assetsSubDirectory: 'static',
28 | assetsPublicPath: '',
29 | productionSourceMap: true
30 | },
31 | dev: {
32 | env: require('./dev.env'),
33 | port: 8383,
34 | assetsSubDirectory: 'static',
35 | assetsPublicPath: '/',
36 | proxyTable: {},
37 | // CSS Sourcemaps off by default because relative paths are "buggy"
38 | // with this option, according to the CSS-Loader README
39 | // (https://github.com/webpack/css-loader#sourcemaps)
40 | // In our experience, they generally work as expected,
41 | // just be aware of this issue when enabling this option.
42 | cssSourceMap: false
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/config/prod.env.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | NODE_ENV: '"production"'
3 | }
4 |
--------------------------------------------------------------------------------
/config/test.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var devEnv = require('./dev.env')
3 |
4 | module.exports = merge(devEnv, {
5 | NODE_ENV: '"testing"'
6 | })
7 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | vue-datatables
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/demo/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
28 |
29 |
30 |
31 |
32 |
99 |
100 |
115 |
--------------------------------------------------------------------------------
/demo/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import $ from 'jquery'
3 | require('datatables.net-bs')(window, $)
4 | import VueResource from 'vue-resource'
5 | import VueDataTables from '../../src/main'
6 | // import VueDataTables from 'vue-datatables'
7 |
8 | import App from './App.vue'
9 |
10 | Vue.use(VueResource)
11 | Vue.use(VueDataTables)
12 |
13 | new Vue({
14 | el: '#app',
15 | render: h => h(App)
16 | })
17 |
--------------------------------------------------------------------------------
/demo/src/sass/_actions.scss:
--------------------------------------------------------------------------------
1 | $primary: #3498cb;
2 | $success: #38ae67;
3 | $info: #2ea8e5;
4 | $warning: #fc6d26;
5 | $danger: #e52c5a;
6 |
7 | @mixin action-variant($color) {
8 | &:focus,
9 | &:hover,
10 | a:focus,
11 | a:hover {
12 | color: $color;
13 | text-decoration: none;
14 | }
15 | }
16 |
17 | .action {
18 | color: #666;
19 | cursor: pointer;
20 | transition: all .1s linear;
21 |
22 | a {
23 | color: #666;
24 | cursor: pointer;
25 | transition: all .1s linear;
26 | }
27 |
28 | .fa {
29 | font-size: 16px;
30 | }
31 |
32 | &+.action {
33 | margin-left: 8px;
34 | }
35 | }
36 |
37 | .action-default {
38 | @include action-variant(#6B6B6B);
39 | }
40 |
41 | .action-primary {
42 | @include action-variant($primary);
43 | }
44 |
45 | .action-danger {
46 | @include action-variant($danger);
47 | }
48 |
49 | .action-warning {
50 | @include action-variant($warning);
51 | }
52 |
53 | .action-success {
54 | @include action-variant($success);
55 | }
56 |
--------------------------------------------------------------------------------
/demo/src/sass/app.scss:
--------------------------------------------------------------------------------
1 | @import 'node_modules/datatables.net-bs/css/dataTables.bootstrap';
2 | @import 'node_modules/datatables.net-responsive-bs/css/responsive.bootstrap';
3 |
4 | @import 'actions.scss';
5 |
6 | #app {
7 | margin-top: 60px;
8 | }
9 |
10 | .inline-block {
11 | display: inline-block;
12 | }
13 |
--------------------------------------------------------------------------------
/demo/src/sass/dataTables.bootstrap-fa.scss:
--------------------------------------------------------------------------------
1 | table.dataTable {
2 | clear: both;
3 | margin-top: 6px !important;
4 | margin-bottom: 6px !important;
5 | max-width: none !important;
6 | // border-collapse: separate !important;
7 |
8 | td,
9 | th {
10 | box-sizing: content-box;
11 |
12 | &.dataTables_empty {
13 | text-align: center;
14 | }
15 | }
16 |
17 | // Style options for the table. Foundation provides its own, but it is also
18 | // useful to have a few more for DataTables
19 | &.nowrap {
20 | th,
21 | td {
22 | white-space: nowrap;
23 | }
24 | }
25 | }
26 |
27 |
28 | // DataTables' built in feature elements
29 | div.dataTables_wrapper {
30 | div.dataTables_length {
31 | label {
32 | font-weight: normal;
33 | text-align: left;
34 | white-space: nowrap;
35 | }
36 |
37 | select {
38 | width: 75px;
39 | display: inline-block;
40 | }
41 | }
42 |
43 | div.dataTables_filter {
44 | text-align: right;
45 |
46 | label {
47 | font-weight: normal;
48 | white-space: nowrap;
49 | text-align: left;
50 | }
51 |
52 | input {
53 | margin-left: 0.5em;
54 | display: inline-block;
55 | width: auto;
56 | }
57 | }
58 |
59 | div.dataTables_info {
60 | padding-top: 8px;
61 | white-space: nowrap;
62 | }
63 |
64 | div.dataTables_paginate {
65 | margin: 0;
66 | white-space: nowrap;
67 | text-align: right;
68 |
69 | ul.pagination {
70 | margin: 2px 0;
71 | white-space: nowrap;
72 | }
73 | }
74 |
75 | div.dataTables_processing {
76 | position: absolute;
77 | top: 50%;
78 | left: 50%;
79 | width: 200px;
80 | margin-left: -100px;
81 | margin-top: -26px;
82 | text-align: center;
83 | padding: 1em 0;
84 | }
85 | }
86 |
87 |
88 | // Sorting - using Glyphicons
89 | table.dataTable thead {
90 | > tr > th,
91 | > tr > td {
92 | &.sorting_asc,
93 | &.sorting_desc,
94 | &.sorting {
95 | padding-right: 30px;
96 | }
97 |
98 | &:active {
99 | outline: none;
100 | }
101 | }
102 |
103 | .sorting,
104 | .sorting_asc,
105 | .sorting_desc,
106 | .sorting_asc_disabled,
107 | .sorting_desc_disabled {
108 | cursor: pointer;
109 | position: relative;
110 |
111 | &:after {
112 | position: absolute;
113 | bottom: 8px;
114 | right: 8px;
115 | display: block;
116 | font-family: 'FontAwesome';
117 | opacity: 0.5;
118 | }
119 | }
120 |
121 | .sorting:after {
122 | opacity: 0.2;
123 | content: "\f0dc"; /* sort */
124 | }
125 |
126 | .sorting_asc:after {
127 | content: "\f0de"; /* sort-by-attributes */
128 | }
129 |
130 | .sorting_desc:after {
131 | content: "\f0dd"; /* sort-by-attributes-alt */
132 | }
133 |
134 | .sorting_asc_disabled:after,
135 | .sorting_desc_disabled:after {
136 | color: #eee;
137 | }
138 | }
139 |
140 |
141 | // Scrolling
142 | div.dataTables_scrollHead table.dataTable {
143 | margin-bottom: 0 !important;
144 | }
145 |
146 | div.dataTables_scrollBody {
147 | table {
148 | border-top: none;
149 | margin-top: 0 !important;
150 | margin-bottom: 0 !important;
151 |
152 | thead { // Hide sort icons
153 | .sorting:after,
154 | .sorting_asc:after,
155 | .sorting_desc:after {
156 | display: none;
157 | }
158 | }
159 |
160 | tbody tr:first-child th,
161 | tbody tr:first-child td {
162 | border-top: none;
163 | }
164 | }
165 | }
166 |
167 | div.dataTables_scrollFoot table {
168 | margin-top: 0 !important;
169 | border-top: none;
170 | }
171 |
172 |
173 | // Responsive
174 | @media screen and (max-width: 767px) {
175 | div.dataTables_wrapper {
176 | div.dataTables_length,
177 | div.dataTables_filter,
178 | div.dataTables_info,
179 | div.dataTables_paginate {
180 | text-align: center;
181 | }
182 | }
183 | }
184 |
185 |
186 | //
187 | // Bootstrap provides a range of styling options for table's via class name
188 | // that we want to full support. They sometimes require some customisations
189 | //
190 |
191 | // Condensed
192 | table.dataTable.table-condensed {
193 | > thead > tr > th {
194 | padding-right: 20px;
195 | }
196 |
197 | .sorting:after,
198 | .sorting_asc:after,
199 | .sorting_desc:after {
200 | top: 6px;
201 | right: 6px;
202 | }
203 | }
204 |
205 | // Frustratingly the border-collapse:collapse used by Bootstrap makes the column
206 | // width calculations when using scrolling impossible to align columns. We have
207 | // to use `border-collapse: separate`
208 | table.table-bordered.dataTable {
209 | th,
210 | td {
211 | border-left-width: 0;
212 |
213 | &:last-child,
214 | &:last-child {
215 | border-right-width: 0;
216 | }
217 | }
218 |
219 | tbody th,
220 | tbody td {
221 | border-bottom-width: 0;
222 | }
223 | }
224 |
225 | // Bordered table
226 | div.dataTables_scrollHead table.table-bordered {
227 | border-bottom-width: 0;
228 | }
229 |
230 | // Responsive tables. We use rows inside the Bootstrap responsive wrapper,
231 | // so they need to have their margin and padding removed
232 | div.table-responsive > div.dataTables_wrapper > div.row {
233 | margin: 0;
234 |
235 | > div[class^="col-"] {
236 | &:first-child {
237 | padding-left: 0;
238 | }
239 | &:last-child {
240 | padding-right: 0;
241 | }
242 | }
243 | }
244 |
245 |
--------------------------------------------------------------------------------
/demo/static/users.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": [
3 | {
4 | "name": "Tiger Nixon",
5 | "position": "System Architect",
6 | "salary": "$320,800",
7 | "start_date": "2011/04/25",
8 | "office": "Edinburgh",
9 | "extn": "5421"
10 | },
11 | {
12 | "name": "Garrett Winters",
13 | "position": "Accountant",
14 | "salary": "$170,750",
15 | "start_date": "2011/07/25",
16 | "office": "Tokyo",
17 | "extn": "8422"
18 | },
19 | {
20 | "name": "Ashton Cox",
21 | "position": "Junior Technical Author",
22 | "salary": "$86,000",
23 | "start_date": "2009/01/12",
24 | "office": "San Francisco",
25 | "extn": "1562"
26 | },
27 | {
28 | "name": "Cedric Kelly",
29 | "position": "Senior Javascript Developer",
30 | "salary": "$433,060",
31 | "start_date": "2012/03/29",
32 | "office": "Edinburgh",
33 | "extn": "6224"
34 | },
35 | {
36 | "name": "Airi Satou",
37 | "position": "Accountant",
38 | "salary": "$162,700",
39 | "start_date": "2008/11/28",
40 | "office": "Tokyo",
41 | "extn": "5407"
42 | },
43 | {
44 | "name": "Brielle Williamson",
45 | "position": "Integration Specialist",
46 | "salary": "$372,000",
47 | "start_date": "2012/12/02",
48 | "office": "New York",
49 | "extn": "4804"
50 | },
51 | {
52 | "name": "Herrod Chandler",
53 | "position": "Sales Assistant",
54 | "salary": "$137,500",
55 | "start_date": "2012/08/06",
56 | "office": "San Francisco",
57 | "extn": "9608"
58 | },
59 | {
60 | "name": "Rhona Davidson",
61 | "position": "Integration Specialist",
62 | "salary": "$327,900",
63 | "start_date": "2010/10/14",
64 | "office": "Tokyo",
65 | "extn": "6200"
66 | },
67 | {
68 | "name": "Colleen Hurst",
69 | "position": "Javascript Developer",
70 | "salary": "$205,500",
71 | "start_date": "2009/09/15",
72 | "office": "San Francisco",
73 | "extn": "2360"
74 | },
75 | {
76 | "name": "Sonya Frost",
77 | "position": "Software Engineer",
78 | "salary": "$103,600",
79 | "start_date": "2008/12/13",
80 | "office": "Edinburgh",
81 | "extn": "1667"
82 | },
83 | {
84 | "name": "Jena Gaines",
85 | "position": "Office Manager",
86 | "salary": "$90,560",
87 | "start_date": "2008/12/19",
88 | "office": "London",
89 | "extn": "3814"
90 | },
91 | {
92 | "name": "Quinn Flynn",
93 | "position": "Support Lead",
94 | "salary": "$342,000",
95 | "start_date": "2013/03/03",
96 | "office": "Edinburgh",
97 | "extn": "9497"
98 | },
99 | {
100 | "name": "Charde Marshall",
101 | "position": "Regional Director",
102 | "salary": "$470,600",
103 | "start_date": "2008/10/16",
104 | "office": "San Francisco",
105 | "extn": "6741"
106 | },
107 | {
108 | "name": "Haley Kennedy",
109 | "position": "Senior Marketing Designer",
110 | "salary": "$313,500",
111 | "start_date": "2012/12/18",
112 | "office": "London",
113 | "extn": "3597"
114 | },
115 | {
116 | "name": "Tatyana Fitzpatrick",
117 | "position": "Regional Director",
118 | "salary": "$385,750",
119 | "start_date": "2010/03/17",
120 | "office": "London",
121 | "extn": "1965"
122 | },
123 | {
124 | "name": "Michael Silva",
125 | "position": "Marketing Designer",
126 | "salary": "$198,500",
127 | "start_date": "2012/11/27",
128 | "office": "London",
129 | "extn": "1581"
130 | },
131 | {
132 | "name": "Paul Byrd",
133 | "position": "Chief Financial Officer (CFO)",
134 | "salary": "$725,000",
135 | "start_date": "2010/06/09",
136 | "office": "New York",
137 | "extn": "3059"
138 | },
139 | {
140 | "name": "Gloria Little",
141 | "position": "Systems Administrator",
142 | "salary": "$237,500",
143 | "start_date": "2009/04/10",
144 | "office": "New York",
145 | "extn": "1721"
146 | },
147 | {
148 | "name": "Bradley Greer",
149 | "position": "Software Engineer",
150 | "salary": "$132,000",
151 | "start_date": "2012/10/13",
152 | "office": "London",
153 | "extn": "2558"
154 | },
155 | {
156 | "name": "Dai Rios",
157 | "position": "Personnel Lead",
158 | "salary": "$217,500",
159 | "start_date": "2012/09/26",
160 | "office": "Edinburgh",
161 | "extn": "2290"
162 | },
163 | {
164 | "name": "Jenette Caldwell",
165 | "position": "Development Lead",
166 | "salary": "$345,000",
167 | "start_date": "2011/09/03",
168 | "office": "New York",
169 | "extn": "1937"
170 | },
171 | {
172 | "name": "Yuri Berry",
173 | "position": "Chief Marketing Officer (CMO)",
174 | "salary": "$675,000",
175 | "start_date": "2009/06/25",
176 | "office": "New York",
177 | "extn": "6154"
178 | },
179 | {
180 | "name": "Caesar Vance",
181 | "position": "Pre-Sales Support",
182 | "salary": "$106,450",
183 | "start_date": "2011/12/12",
184 | "office": "New York",
185 | "extn": "8330"
186 | },
187 | {
188 | "name": "Doris Wilder",
189 | "position": "Sales Assistant",
190 | "salary": "$85,600",
191 | "start_date": "2010/09/20",
192 | "office": "Sidney",
193 | "extn": "3023"
194 | },
195 | {
196 | "name": "Angelica Ramos",
197 | "position": "Chief Executive Officer (CEO)",
198 | "salary": "$1,200,000",
199 | "start_date": "2009/10/09",
200 | "office": "London",
201 | "extn": "5797"
202 | },
203 | {
204 | "name": "Gavin Joyce",
205 | "position": "Developer",
206 | "salary": "$92,575",
207 | "start_date": "2010/12/22",
208 | "office": "Edinburgh",
209 | "extn": "8822"
210 | },
211 | {
212 | "name": "Jennifer Chang",
213 | "position": "Regional Director",
214 | "salary": "$357,650",
215 | "start_date": "2010/11/14",
216 | "office": "Singapore",
217 | "extn": "9239"
218 | },
219 | {
220 | "name": "Brenden Wagner",
221 | "position": "Software Engineer",
222 | "salary": "$206,850",
223 | "start_date": "2011/06/07",
224 | "office": "San Francisco",
225 | "extn": "1314"
226 | },
227 | {
228 | "name": "Fiona Green",
229 | "position": "Chief Operating Officer (COO)",
230 | "salary": "$850,000",
231 | "start_date": "2010/03/11",
232 | "office": "San Francisco",
233 | "extn": "2947"
234 | },
235 | {
236 | "name": "Shou Itou",
237 | "position": "Regional Marketing",
238 | "salary": "$163,000",
239 | "start_date": "2011/08/14",
240 | "office": "Tokyo",
241 | "extn": "8899"
242 | },
243 | {
244 | "name": "Michelle House",
245 | "position": "Integration Specialist",
246 | "salary": "$95,400",
247 | "start_date": "2011/06/02",
248 | "office": "Sidney",
249 | "extn": "2769"
250 | },
251 | {
252 | "name": "Suki Burks",
253 | "position": "Developer",
254 | "salary": "$114,500",
255 | "start_date": "2009/10/22",
256 | "office": "London",
257 | "extn": "6832"
258 | },
259 | {
260 | "name": "Prescott Bartlett",
261 | "position": "Technical Author",
262 | "salary": "$145,000",
263 | "start_date": "2011/05/07",
264 | "office": "London",
265 | "extn": "3606"
266 | },
267 | {
268 | "name": "Gavin Cortez",
269 | "position": "Team Leader",
270 | "salary": "$235,500",
271 | "start_date": "2008/10/26",
272 | "office": "San Francisco",
273 | "extn": "2860"
274 | },
275 | {
276 | "name": "Martena Mccray",
277 | "position": "Post-Sales support",
278 | "salary": "$324,050",
279 | "start_date": "2011/03/09",
280 | "office": "Edinburgh",
281 | "extn": "8240"
282 | },
283 | {
284 | "name": "Unity Butler",
285 | "position": "Marketing Designer",
286 | "salary": "$85,675",
287 | "start_date": "2009/12/09",
288 | "office": "San Francisco",
289 | "extn": "5384"
290 | },
291 | {
292 | "name": "Howard Hatfield",
293 | "position": "Office Manager",
294 | "salary": "$164,500",
295 | "start_date": "2008/12/16",
296 | "office": "San Francisco",
297 | "extn": "7031"
298 | },
299 | {
300 | "name": "Hope Fuentes",
301 | "position": "Secretary",
302 | "salary": "$109,850",
303 | "start_date": "2010/02/12",
304 | "office": "San Francisco",
305 | "extn": "6318"
306 | },
307 | {
308 | "name": "Vivian Harrell",
309 | "position": "Financial Controller",
310 | "salary": "$452,500",
311 | "start_date": "2009/02/14",
312 | "office": "San Francisco",
313 | "extn": "9422"
314 | },
315 | {
316 | "name": "Timothy Mooney",
317 | "position": "Office Manager",
318 | "salary": "$136,200",
319 | "start_date": "2008/12/11",
320 | "office": "London",
321 | "extn": "7580"
322 | },
323 | {
324 | "name": "Jackson Bradshaw",
325 | "position": "Director",
326 | "salary": "$645,750",
327 | "start_date": "2008/09/26",
328 | "office": "New York",
329 | "extn": "1042"
330 | },
331 | {
332 | "name": "Olivia Liang",
333 | "position": "Support Engineer",
334 | "salary": "$234,500",
335 | "start_date": "2011/02/03",
336 | "office": "Singapore",
337 | "extn": "2120"
338 | },
339 | {
340 | "name": "Bruno Nash",
341 | "position": "Software Engineer",
342 | "salary": "$163,500",
343 | "start_date": "2011/05/03",
344 | "office": "London",
345 | "extn": "6222"
346 | },
347 | {
348 | "name": "Sakura Yamamoto",
349 | "position": "Support Engineer",
350 | "salary": "$139,575",
351 | "start_date": "2009/08/19",
352 | "office": "Tokyo",
353 | "extn": "9383"
354 | },
355 | {
356 | "name": "Thor Walton",
357 | "position": "Developer",
358 | "salary": "$98,540",
359 | "start_date": "2013/08/11",
360 | "office": "New York",
361 | "extn": "8327"
362 | },
363 | {
364 | "name": "Finn Camacho",
365 | "position": "Support Engineer",
366 | "salary": "$87,500",
367 | "start_date": "2009/07/07",
368 | "office": "San Francisco",
369 | "extn": "2927"
370 | },
371 | {
372 | "name": "Serge Baldwin",
373 | "position": "Data Coordinator",
374 | "salary": "$138,575",
375 | "start_date": "2012/04/09",
376 | "office": "Singapore",
377 | "extn": "8352"
378 | },
379 | {
380 | "name": "Zenaida Frank",
381 | "position": "Software Engineer",
382 | "salary": "$125,250",
383 | "start_date": "2010/01/04",
384 | "office": "New York",
385 | "extn": "7439"
386 | },
387 | {
388 | "name": "Zorita Serrano",
389 | "position": "Software Engineer",
390 | "salary": "$115,000",
391 | "start_date": "2012/06/01",
392 | "office": "San Francisco",
393 | "extn": "4389"
394 | },
395 | {
396 | "name": "Jennifer Acosta",
397 | "position": "Junior Javascript Developer",
398 | "salary": "$75,650",
399 | "start_date": "2013/02/01",
400 | "office": "Edinburgh",
401 | "extn": "3431"
402 | },
403 | {
404 | "name": "Cara Stevens",
405 | "position": "Sales Assistant",
406 | "salary": "$145,600",
407 | "start_date": "2011/12/06",
408 | "office": "New York",
409 | "extn": "3990"
410 | },
411 | {
412 | "name": "Hermione Butler",
413 | "position": "Regional Director",
414 | "salary": "$356,250",
415 | "start_date": "2011/03/21",
416 | "office": "London",
417 | "extn": "1016"
418 | },
419 | {
420 | "name": "Lael Greer",
421 | "position": "Systems Administrator",
422 | "salary": "$103,500",
423 | "start_date": "2009/02/27",
424 | "office": "London",
425 | "extn": "6733"
426 | },
427 | {
428 | "name": "Jonas Alexander",
429 | "position": "Developer",
430 | "salary": "$86,500",
431 | "start_date": "2010/07/14",
432 | "office": "San Francisco",
433 | "extn": "8196"
434 | },
435 | {
436 | "name": "Shad Decker",
437 | "position": "Regional Director",
438 | "salary": "$183,000",
439 | "start_date": "2008/11/13",
440 | "office": "Edinburgh",
441 | "extn": "6373"
442 | },
443 | {
444 | "name": "Michael Bruce",
445 | "position": "Javascript Developer",
446 | "salary": "$183,000",
447 | "start_date": "2011/06/27",
448 | "office": "Singapore",
449 | "extn": "5384"
450 | },
451 | {
452 | "name": "Donna Snider",
453 | "position": "Customer Support",
454 | "salary": "$112,000",
455 | "start_date": "2011/01/25",
456 | "office": "New York",
457 | "extn": "4226"
458 | }
459 | ]
460 | }
461 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-datatables",
3 | "version": "0.2.0",
4 | "description": "A Vue component for DataTables.",
5 | "main": "lib/vue-datatables.js",
6 | "scripts": {
7 | "prepublish": "npm run build",
8 | "dev": "node build/dev-server.js",
9 | "build": "webpack --config build/webpack.build.conf.js",
10 | "unit": "karma start test/unit/karma.conf.js --single-run",
11 | "e2e": "node test/e2e/runner.js",
12 | "test": "npm run unit && npm run e2e",
13 | "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
14 | },
15 | "author": "Cretu Eusebiu",
16 | "repository": {
17 | "type": "git",
18 | "url": "git+https://github.com/cretueusebiu/vue-datatables.git"
19 | },
20 | "license": "MIT",
21 | "keywords": [
22 | "vue",
23 | "datatables"
24 | ],
25 | "bugs": {
26 | "url": "https://github.com/cretueusebiu/vue-datatables/issues"
27 | },
28 | "devDependencies": {
29 | "autoprefixer": "^6.4.0",
30 | "babel-core": "^6.0.0",
31 | "babel-eslint": "^7.0.0",
32 | "babel-loader": "^6.0.0",
33 | "babel-plugin-transform-runtime": "^6.0.0",
34 | "babel-preset-es2015": "^6.0.0",
35 | "babel-preset-stage-2": "^6.0.0",
36 | "babel-register": "^6.0.0",
37 | "chai": "^3.5.0",
38 | "chalk": "^1.1.3",
39 | "chromedriver": "^2.21.2",
40 | "connect-history-api-fallback": "^1.1.0",
41 | "cross-spawn": "^4.0.2",
42 | "css-loader": "^0.25.0",
43 | "datatables.net-bs": "^1.10.12",
44 | "datatables.net-responsive-bs": "^2.1.0",
45 | "eslint": "^3.8.1",
46 | "eslint-config-vue": "^1.1.0",
47 | "eslint-friendly-formatter": "^2.0.5",
48 | "eslint-loader": "^1.5.0",
49 | "eslint-plugin-html": "^1.5.5",
50 | "eslint-plugin-promise": "^2.0.1",
51 | "eslint-plugin-vue": "^0.1.1",
52 | "eventsource-polyfill": "^0.9.6",
53 | "express": "^4.13.3",
54 | "extract-text-webpack-plugin": "^1.0.1",
55 | "file-loader": "^0.9.0",
56 | "function-bind": "^1.0.2",
57 | "html-webpack-plugin": "^2.8.1",
58 | "http-proxy-middleware": "^0.17.2",
59 | "imports-loader": "^0.6.5",
60 | "inject-loader": "^2.0.1",
61 | "isparta-loader": "^2.0.0",
62 | "jquery": "^3.1.1",
63 | "json-loader": "^0.5.4",
64 | "karma": "^1.3.0",
65 | "karma-coverage": "^1.1.1",
66 | "karma-mocha": "^1.2.0",
67 | "karma-phantomjs-launcher": "^1.0.0",
68 | "karma-sinon-chai": "^1.2.0",
69 | "karma-sourcemap-loader": "^0.3.7",
70 | "karma-spec-reporter": "0.0.26",
71 | "karma-webpack": "^1.7.0",
72 | "lolex": "^1.4.0",
73 | "mocha": "^3.1.0",
74 | "nightwatch": "^0.9.8",
75 | "node-sass": "^3.10.1",
76 | "opn": "^4.0.2",
77 | "ora": "^0.3.0",
78 | "phantomjs-prebuilt": "^2.1.3",
79 | "sass-loader": "^4.0.2",
80 | "selenium-server": "2.53.1",
81 | "semver": "^5.3.0",
82 | "shelljs": "^0.7.4",
83 | "sinon": "^1.17.3",
84 | "sinon-chai": "^2.8.0",
85 | "url-loader": "^0.5.7",
86 | "vue": "^2.0.3",
87 | "vue-loader": "^9.4.0",
88 | "vue-resource": "^1.0.3",
89 | "vue-style-loader": "^1.0.0",
90 | "webpack": "^1.13.2",
91 | "webpack-dev-middleware": "^1.8.3",
92 | "webpack-hot-middleware": "^2.12.2",
93 | "webpack-merge": "^0.14.1"
94 | },
95 | "engines": {
96 | "node": ">= 4.0.0",
97 | "npm": ">= 3.0.0"
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/components/DataTable.vue:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
437 |
--------------------------------------------------------------------------------
/src/components/Filter.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
35 |
--------------------------------------------------------------------------------
/src/components/PerPage.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
36 |
--------------------------------------------------------------------------------
/src/components/Search.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
33 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import plugin from './plugin'
2 | import Search from './components/Search.vue'
3 | import Filter from './components/Filter.vue'
4 | import PerPage from './components/PerPage.vue'
5 | import DataTable from './components/DataTable.vue'
6 |
7 | export {
8 | Search,
9 | Filter,
10 | PerPage,
11 | DataTable,
12 | plugin as VueDataTables
13 | }
14 |
15 | export default plugin
16 |
--------------------------------------------------------------------------------
/src/options.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | const defaults = {
4 | dom: `
5 | <'row'<'col-sm-12'tr>>
6 | <'row'<'col-sm-5'i><'col-sm-7'p>>
7 | `,
8 |
9 | language: {
10 | search: '_INPUT_',
11 | searchPlaceholder: 'Search...',
12 | lengthMenu: '_MENU_',
13 | paginate: {
14 | previous: '«',
15 | next: '»'
16 | }
17 | },
18 |
19 | perPage: 10,
20 |
21 | perPageOptions: [10, 25, 50, 75, 100],
22 |
23 | tableClass: 'table table-bordered table-striped table-hover dtr-inline',
24 |
25 | /**
26 | * Use vue-resource instead of jQuery.
27 | *
28 | * @param {Object} data
29 | * @param {Function} callback
30 | * @param {Object} settings
31 | */
32 | ajax (data, callback) {
33 | const params = { ...this.params, ...data }
34 |
35 | // vue-resource bug
36 | // https://github.com/vuejs/vue-resource/pull/449
37 | params._length = params.length
38 | delete params.length
39 |
40 | Vue.http.get(this.url, { params }).then(({ body }) => {
41 | callback(body)
42 | })
43 | }
44 | }
45 |
46 | /**
47 | * Merge the given options into the default options.
48 | *
49 | * @param {Object} options
50 | */
51 | const merge = function merge (options) {
52 | Object.assign(defaults, options)
53 | }
54 |
55 | export { merge }
56 | export default defaults
57 |
--------------------------------------------------------------------------------
/src/plugin.js:
--------------------------------------------------------------------------------
1 | import { merge } from './options'
2 | import Search from './components/Search.vue'
3 | import Filter from './components/Filter.vue'
4 | import PerPage from './components/PerPage.vue'
5 | import DataTable from './components/DataTable.vue'
6 |
7 | export default {
8 | install (Vue, options = {}) {
9 | merge(options)
10 |
11 | Vue.component('datatable', DataTable)
12 | Vue.component('datatable-filter', Filter)
13 | Vue.component('datatable-search', Search)
14 | Vue.component('datatable-perpage', PerPage)
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/util.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Determine if the given callable is valid.
3 | *
4 | * @param {Array|Function} callable
5 | * @param {String} message
6 | */
7 | const validCallable = function validCallable (callable) {
8 | return Array.isArray(callable) || typeof callable === 'function'
9 | }
10 |
11 | /**
12 | * Call function.
13 | *
14 | * @param {Array|Function} callable
15 | * @param {Array} args
16 | * @param {Object} dScope
17 | * @return {Any}
18 | */
19 | const call = function call (callable, args = [], dScope) {
20 | if (Array.isArray(callable)) {
21 | const [scope, func] = callable
22 |
23 | return scope[func].apply(scope, args)
24 | } else {
25 | return callable.apply(dScope, args)
26 | }
27 | }
28 |
29 | export { call, validCallable }
30 |
--------------------------------------------------------------------------------
/test/e2e/custom-assertions/elementCount.js:
--------------------------------------------------------------------------------
1 | // A custom Nightwatch assertion.
2 | // the name of the method is the filename.
3 | // can be used in tests like this:
4 | //
5 | // browser.assert.elementCount(selector, count)
6 | //
7 | // for how to write custom assertions see
8 | // http://nightwatchjs.org/guide#writing-custom-assertions
9 | exports.assertion = function (selector, count) {
10 | this.message = 'Testing if element <' + selector + '> has count: ' + count
11 | this.expected = count
12 | this.pass = function (val) {
13 | return val === this.expected
14 | }
15 | this.value = function (res) {
16 | return res.value
17 | }
18 | this.command = function (cb) {
19 | var self = this
20 | return this.api.execute(function (selector) {
21 | return document.querySelectorAll(selector).length
22 | }, [selector], function (res) {
23 | cb.call(self, res)
24 | })
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/e2e/nightwatch.conf.js:
--------------------------------------------------------------------------------
1 | require('babel-register')
2 | var config = require('../../config')
3 |
4 | // http://nightwatchjs.org/guide#settings-file
5 | module.exports = {
6 | "src_folders": ["test/e2e/specs"],
7 | "output_folder": "test/e2e/reports",
8 | "custom_assertions_path": ["test/e2e/custom-assertions"],
9 |
10 | "selenium": {
11 | "start_process": true,
12 | "server_path": "node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar",
13 | "host": "127.0.0.1",
14 | "port": 4444,
15 | "cli_args": {
16 | "webdriver.chrome.driver": require('chromedriver').path
17 | }
18 | },
19 |
20 | "test_settings": {
21 | "default": {
22 | "selenium_port": 4444,
23 | "selenium_host": "localhost",
24 | "silent": true,
25 | "globals": {
26 | "devServerURL": "http://localhost:" + (process.env.PORT || config.dev.port)
27 | }
28 | },
29 |
30 | "chrome": {
31 | "desiredCapabilities": {
32 | "browserName": "chrome",
33 | "javascriptEnabled": true,
34 | "acceptSslCerts": true
35 | }
36 | },
37 |
38 | "firefox": {
39 | "desiredCapabilities": {
40 | "browserName": "firefox",
41 | "javascriptEnabled": true,
42 | "acceptSslCerts": true
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/test/e2e/runner.js:
--------------------------------------------------------------------------------
1 | // 1. start the dev server using production config
2 | process.env.NODE_ENV = 'testing'
3 | var server = require('../../build/dev-server.js')
4 |
5 | // 2. run the nightwatch test suite against it
6 | // to run in additional browsers:
7 | // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
8 | // 2. add it to the --env flag below
9 | // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
10 | // For more information on Nightwatch's config file, see
11 | // http://nightwatchjs.org/guide#settings-file
12 | var opts = process.argv.slice(2)
13 | if (opts.indexOf('--config') === -1) {
14 | opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
15 | }
16 | if (opts.indexOf('--env') === -1) {
17 | opts = opts.concat(['--env', 'chrome'])
18 | }
19 |
20 | var spawn = require('cross-spawn')
21 | var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
22 |
23 | runner.on('exit', function (code) {
24 | server.close()
25 | process.exit(code)
26 | })
27 |
28 | runner.on('error', function (err) {
29 | server.close()
30 | throw err
31 | })
32 |
--------------------------------------------------------------------------------
/test/e2e/specs/test.js:
--------------------------------------------------------------------------------
1 | // For authoring Nightwatch tests, see
2 | // http://nightwatchjs.org/guide#usage
3 |
4 | module.exports = {
5 | 'default e2e tests': function (browser) {
6 | // automatically uses dev Server port from /config.index.js
7 | // default: http://localhost:8080
8 | // see nightwatch.conf.js
9 | const devServer = browser.globals.devServerURL
10 |
11 | browser
12 | .url(devServer)
13 | .waitForElementVisible('#app', 5000)
14 | .assert.elementPresent('.hello')
15 | .assert.containsText('h1', 'Welcome to Your Vue.js App')
16 | .assert.elementCount('img', 1)
17 | .end()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/test/unit/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "mocha": true
4 | },
5 | "globals": {
6 | "expect": true,
7 | "sinon": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/unit/index.js:
--------------------------------------------------------------------------------
1 | // Polyfill fn.bind() for PhantomJS
2 | /* eslint-disable no-extend-native */
3 | Function.prototype.bind = require('function-bind')
4 |
5 | // require all test files (files that ends with .spec.js)
6 | const testsContext = require.context('./specs', true, /\.spec$/)
7 | testsContext.keys().forEach(testsContext)
8 |
9 | // require all src files except main.js for coverage.
10 | // you can also change this to match only the subset of files that
11 | // you want coverage for.
12 | const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
13 | srcContext.keys().forEach(srcContext)
14 |
--------------------------------------------------------------------------------
/test/unit/karma.conf.js:
--------------------------------------------------------------------------------
1 | // This is a karma config file. For more details see
2 | // http://karma-runner.github.io/0.13/config/configuration-file.html
3 | // we are also using it with karma-webpack
4 | // https://github.com/webpack/karma-webpack
5 |
6 | var path = require('path')
7 | var merge = require('webpack-merge')
8 | var baseConfig = require('../../build/webpack.base.conf')
9 | var utils = require('../../build/utils')
10 | var webpack = require('webpack')
11 | var projectRoot = path.resolve(__dirname, '../../')
12 |
13 | var webpackConfig = merge(baseConfig, {
14 | // use inline sourcemap for karma-sourcemap-loader
15 | module: {
16 | loaders: utils.styleLoaders()
17 | },
18 | devtool: '#inline-source-map',
19 | vue: {
20 | loaders: {
21 | js: 'isparta'
22 | }
23 | },
24 | plugins: [
25 | new webpack.DefinePlugin({
26 | 'process.env': require('../../config/test.env')
27 | })
28 | ]
29 | })
30 |
31 | // no need for app entry during tests
32 | delete webpackConfig.entry
33 |
34 | // make sure isparta loader is applied before eslint
35 | webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || []
36 | webpackConfig.module.preLoaders.unshift({
37 | test: /\.js$/,
38 | loader: 'isparta',
39 | include: path.resolve(projectRoot, 'src')
40 | })
41 |
42 | // only apply babel for test files when using isparta
43 | webpackConfig.module.loaders.some(function (loader, i) {
44 | if (loader.loader === 'babel') {
45 | loader.include = path.resolve(projectRoot, 'test/unit')
46 | return true
47 | }
48 | })
49 |
50 | module.exports = function (config) {
51 | config.set({
52 | // to run in additional browsers:
53 | // 1. install corresponding karma launcher
54 | // http://karma-runner.github.io/0.13/config/browsers.html
55 | // 2. add it to the `browsers` array below.
56 | browsers: ['PhantomJS'],
57 | frameworks: ['mocha', 'sinon-chai'],
58 | reporters: ['spec', 'coverage'],
59 | files: ['./index.js'],
60 | preprocessors: {
61 | './index.js': ['webpack', 'sourcemap']
62 | },
63 | webpack: webpackConfig,
64 | webpackMiddleware: {
65 | noInfo: true
66 | },
67 | coverageReporter: {
68 | dir: './coverage',
69 | reporters: [
70 | { type: 'lcov', subdir: '.' },
71 | { type: 'text-summary' }
72 | ]
73 | }
74 | })
75 | }
76 |
--------------------------------------------------------------------------------
/test/unit/specs/Hello.spec.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Hello from 'src/components/Hello'
3 |
4 | describe('Hello.vue', () => {
5 | it('should render correct contents', () => {
6 | const vm = new Vue({
7 | el: document.createElement('div'),
8 | render: (h) => h(Hello)
9 | })
10 | expect(vm.$el.querySelector('.hello h1').textContent)
11 | .to.equal('Welcome to Your Vue.js App')
12 | })
13 | })
14 |
--------------------------------------------------------------------------------