diff --git a/dist/qin.js b/dist/qin.js new file mode 100644 index 0000000..bcb446b --- /dev/null +++ b/dist/qin.js @@ -0,0 +1 @@ +!function(t,e){{var o=(Node.prototype,"trigger");t.createElement("i")}NodeList.prototype.forEach=[].forEach,e.on=Node.prototype.on=function(t,e){return this.addEventListener(t,e,!1),this},NodeList.prototype.on=function(t,e){return this[forEach](function(o){o.on(t,e)}),this},Node.prototype.css=function(t,e){var o=this;return"object"!=typeof t?this.style[t]=e:function(t){for(var e in t)o.css(e,t[e])}(t),this},NodeList.prototype.css=function(t,e){return this.forEach(function(o){o.css(t,e)}),this},e[o]=Node.prototype[o]=function(e,o){var n=t.createEvent("HTMLEvents");return n.initEvent(e,!0,!0),n.data=o||{},n.eventName=e,n.target=this,this.dispatchEvent(n),this},NodeList.prototype[o]=function(t){return this[forEach](function(e){e[o](t)}),this};var n=function(e){var o=t.querySelectorAll(e||"body"),n=o.length;return 1==n?o[0]:o};n.on=Node.prototype.on,n[o]=Node.prototype[o],"undefined"!=typeof exports&&module.exports?module.exports=exports=n:"function"==typeof define&&define.cmd?define(function(t,e,o){o.exports=e=n}):"function"==typeof define&&define.amd?define("wechat",[],n):e.$=n}(document,window); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..a731769 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,17 @@ +var gulp = require('gulp'), + uglify = require('gulp-uglify'); + +var paths = { + js: ['qin.js'] +} + +gulp.task('compress', function() { + gulp.src('qin.js') + .pipe(uglify()) + .pipe(gulp.dest('dist')) +}); + +gulp.task('default', function() { + gulp.watch(paths.js, ['compress']) +}) + diff --git a/package.json b/package.json index 067e4c7..c45fd41 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "devDependencies": { "chai": "^1.9.2", "gulp": "*", + "gulp-uglify": "^1.0.1", "mocha": "^1.21.4", "mocha-phantomjs": "^3.5.0", "phantomjs": "^1.9.10" diff --git a/qin.js b/qin.js index 1326023..36968d6 100644 --- a/qin.js +++ b/qin.js @@ -6,7 +6,6 @@ ; (function(document, window) { - var node = Node.prototype, trigger = 'trigger', // 兼容firefox, firefox下创建元素需要一个字符串作为参数