添加grunt-dist任务生成压缩文件

pull/11/head
jaywcjlove 10 years ago
parent 26bc8dae9a
commit c5ff46a87a

1
.gitignore vendored

@ -1 +1,2 @@
node_modules/ node_modules/
dist/

@ -2,6 +2,7 @@ module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-watch' grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-uglify' grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-jshint' grunt.loadNpmTasks 'grunt-contrib-jshint'
grunt.loadNpmTasks 'grunt-dist'
grunt.initConfig( grunt.initConfig(
pkg: grunt.file.readJSON 'package.json' pkg: grunt.file.readJSON 'package.json'
uglify: uglify:
@ -19,6 +20,10 @@ module.exports = (grunt) ->
eqeqeq: true eqeqeq: true
trailing: true trailing: true
files: ['src/hotkeys.js'] files: ['src/hotkeys.js']
dist:
default_options:
files:
"dist":['src/hotkeys.js']
watch: watch:
another: another:
files: ['src/*.js'] files: ['src/*.js']

@ -2,17 +2,29 @@
[![](https://img.shields.io/github/issues/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/issues) [![](https://img.shields.io/github/forks/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/network) [![](https://img.shields.io/github/stars/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/stargazers) [![](https://img.shields.io/github/release/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/releases) [![](https://img.shields.io/github/issues/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/issues) [![](https://img.shields.io/github/forks/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/network) [![](https://img.shields.io/github/stars/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/stargazers) [![](https://img.shields.io/github/release/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/releases)
这又是在重复造轮子,呵呵~ 自定义快捷键没有依赖。这又是在重复造轮子,呵呵~
## 下载 ## 创建
### bower 您将需要在您的系统上安装的 Node.js。
Run `bower info hotkeysjs` to list the available versions.
下载 `bower install hotkeysjs` ```sh
# npm 安装
$ bower install hotkeysjs
# npm 安装
$ npm install hotkeys-js
# 在页面上引用需要压缩的话,运行
$ grunt dist
# 在dist目录中生成下列文件
# dist/hotkeys.js
# dist/hotkeys.min.js
# dist/hotkeys.min.map
```
### npm
下载 `npm install hotkeys-js`
## 定义快捷键 ## 定义快捷键

@ -17,6 +17,7 @@
"grunt": "^0.4.5", "grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.11.2", "grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-uglify": "^0.9.1", "grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "^0.6.1" "grunt-contrib-watch": "^0.6.1",
"grunt-dist": "0.0.3"
} }
} }

@ -6,6 +6,21 @@
<script type="text/javascript" src="../src/hotkeys.js"></script> <script type="text/javascript" src="../src/hotkeys.js"></script>
</head> </head>
<body> <body>
<textarea></textarea>
<div contentEditable="true" style="height: 200px;width: 400px;border: 1px solid red;"></div>
<script type="text/javascript">
hotkeys.filter = function(event){
console.log("message123123123",event.target);
return true;
}
// 定义a快捷键
hotkeys('*',function(event,handler){
//event.srcElement: input
//event.target: input
console.log("message22323:",event.target);
});
</script>
</body> </body>
</html> </html>
Loading…
Cancel
Save