Skip to content

Commit a119e33

Browse files
committed
complete gulp
1 parent 3590599 commit a119e33

File tree

3 files changed

+138
-58
lines changed

3 files changed

+138
-58
lines changed

dist/js/jquery.atwho.js

+45-42
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
1-
/*! jquery.atwho - v1.4.0 %>
2-
* Copyright (c) 2016 chord.luo <[email protected]>;
3-
* homepage: http://ichord.github.com/At.js
4-
* Licensed MIT
5-
*/
6-
(function (root, factory) {
7-
if (typeof define === 'function' && define.amd) {
8-
// AMD. Register as an anonymous module unless amdModuleId is set
9-
define(["jquery"], function (a0) {
10-
return (factory(a0));
11-
});
12-
} else if (typeof exports === 'object') {
13-
// Node. Does not work with strict CommonJS, but
14-
// only CommonJS-like environments that support module.exports,
15-
// like Node.
16-
module.exports = factory(require("jquery"));
17-
} else {
18-
factory(jQuery);
19-
}
20-
}(this, function (jquery) {
21-
22-
var $, Api, App, Controller, DEFAULT_CALLBACKS, EditableController, KEY_CODE, Model, TextareaController, View,
23-
slice = [].slice,
24-
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
25-
hasProp = {}.hasOwnProperty;
26-
27-
$ = jquery;
1+
(function(factory) {
2+
if (typeof define === 'function' && define.amd) {
3+
define(['jquery'], factory);
4+
} else if (typeof exports === 'object') {
5+
factory(require('jquery'));
6+
} else {
7+
factory(jQuery);
8+
}
9+
}(function($) {
10+
var App;
2811

2912
App = (function() {
3013
function App(inputor) {
@@ -45,7 +28,7 @@ App = (function() {
4528
};
4629

4730
App.prototype.setupRootElement = function(iframe, asRoot) {
48-
var error;
31+
var error, error1;
4932
if (asRoot == null) {
5033
asRoot = false;
5134
}
@@ -58,8 +41,8 @@ App = (function() {
5841
this.window = this.document.defaultView || this.document.parentWindow;
5942
try {
6043
this.iframe = this.window.frameElement;
61-
} catch (_error) {
62-
error = _error;
44+
} catch (error1) {
45+
error = error1;
6346
this.iframe = null;
6447
if ($.fn.atwho.debug) {
6548
throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n" + error);
@@ -269,13 +252,16 @@ App = (function() {
269252

270253
})();
271254

255+
var Controller,
256+
slice = [].slice;
257+
272258
Controller = (function() {
273259
Controller.prototype.uid = function() {
274260
return (Math.random().toString(16) + "000000000").substr(2, 8) + (new Date().getTime());
275261
};
276262

277-
function Controller(app1, at1) {
278-
this.app = app1;
263+
function Controller(app, at1) {
264+
this.app = app;
279265
this.at = at1;
280266
this.$inputor = this.app.$inputor;
281267
this.id = this.$inputor[0].id || this.uid();
@@ -305,12 +291,12 @@ Controller = (function() {
305291
};
306292

307293
Controller.prototype.callDefault = function() {
308-
var args, error, funcName;
294+
var args, error, error1, funcName;
309295
funcName = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
310296
try {
311297
return DEFAULT_CALLBACKS[funcName].apply(this, args);
312-
} catch (_error) {
313-
error = _error;
298+
} catch (error1) {
299+
error = error1;
314300
return $.error(error + " Or maybe At.js doesn't have function " + funcName);
315301
}
316302
};
@@ -331,11 +317,11 @@ Controller = (function() {
331317
};
332318

333319
Controller.prototype.getOpt = function(at, default_value) {
334-
var e;
320+
var e, error1;
335321
try {
336322
return this.setting[at];
337-
} catch (_error) {
338-
e = _error;
323+
} catch (error1) {
324+
e = error1;
339325
return null;
340326
}
341327
};
@@ -452,6 +438,10 @@ Controller = (function() {
452438

453439
})();
454440

441+
var TextareaController,
442+
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
443+
hasProp = {}.hasOwnProperty;
444+
455445
TextareaController = (function(superClass) {
456446
extend(TextareaController, superClass);
457447

@@ -530,6 +520,10 @@ TextareaController = (function(superClass) {
530520

531521
})(Controller);
532522

523+
var EditableController,
524+
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
525+
hasProp = {}.hasOwnProperty;
526+
533527
EditableController = (function(superClass) {
534528
extend(EditableController, superClass);
535529

@@ -726,6 +720,8 @@ EditableController = (function(superClass) {
726720

727721
})(Controller);
728722

723+
var Model;
724+
729725
Model = (function() {
730726
function Model(context) {
731727
this.context = context;
@@ -790,6 +786,8 @@ Model = (function() {
790786

791787
})();
792788

789+
var View;
790+
793791
View = (function() {
794792
function View(context) {
795793
this.context = context;
@@ -986,6 +984,8 @@ View = (function() {
986984

987985
})();
988986

987+
var DEFAULT_CALLBACKS, KEY_CODE;
988+
989989
KEY_CODE = {
990990
DOWN: 40,
991991
UP: 38,
@@ -1055,7 +1055,7 @@ DEFAULT_CALLBACKS = {
10551055
});
10561056
},
10571057
tplEval: function(tpl, map) {
1058-
var error, template;
1058+
var error, error1, template;
10591059
template = tpl;
10601060
try {
10611061
if (typeof tpl !== 'string') {
@@ -1064,8 +1064,8 @@ DEFAULT_CALLBACKS = {
10641064
return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
10651065
return map[key];
10661066
});
1067-
} catch (_error) {
1068-
error = _error;
1067+
} catch (error1) {
1068+
error = error1;
10691069
return "";
10701070
}
10711071
},
@@ -1088,6 +1088,8 @@ DEFAULT_CALLBACKS = {
10881088
afterMatchFailed: function(at, el) {}
10891089
};
10901090

1091+
var Api;
1092+
10911093
Api = {
10921094
load: function(at, data) {
10931095
var c;
@@ -1174,4 +1176,5 @@ $.fn.atwho["default"] = {
11741176
$.fn.atwho.debug = false;
11751177

11761178

1177-
}));
1179+
$.fn.Jquery.atwho = Jquery.atwho;
1180+
}));

gulpfile.js

+77-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,79 @@
1-
var gulp = require('gulp');
1+
var gulp = require('gulp'),
2+
coffee = require('gulp-coffee'),
3+
concat = require('gulp-concat'),
4+
umd = require('gulp-umd'),
5+
umdTempl = require('umd-templates'),
6+
uglify = require('gulp-uglify'),
7+
rename = require("gulp-rename"),
8+
cssmin = require('gulp-cssmin'),
9+
jasmine = require('gulp-jasmine-phantom'),
10+
util = require('gulp-util');
211

3-
gulp.task('default', function() {
4-
// place code for your default task here
12+
var name = 'jquery.atwho';
13+
14+
gulp.task('coffee', function() {
15+
gulp.src('src/*.coffee')
16+
.pipe(coffee({bare: true}).on('error', util.log))
17+
.pipe(gulp.dest('./build/js'));
18+
19+
gulp.src('spec/**/*.coffee')
20+
.pipe(coffee({bare: true}).on('error', util.log))
21+
.pipe(gulp.dest('spec/build'))
22+
});
23+
24+
gulp.task('concat', function() {
25+
fileList = [
26+
//'build/js/noConflict.js',
27+
'build/js/app.js',
28+
'build/js/controller.js',
29+
'build/js/textareaController.js',
30+
'build/js/editableController.js',
31+
'build/js/model.js',
32+
'build/js/view.js',
33+
'build/js/default.js',
34+
'build/js/api.js'
35+
]
36+
gulp.src(fileList)
37+
.pipe(concat(name + ".js"))
38+
.pipe(gulp.dest('build'));
39+
});
40+
41+
gulp.task('umd', function() {
42+
gulp.src('build/' + name + ".js")
43+
.pipe(umd({
44+
template: umdTempl.jqueryPluginCommonjs.path
45+
})).pipe(gulp.dest('dist/js'));
46+
});
47+
48+
gulp.task('compress', function() {
49+
gulp.src('dist/js/' + name + '.js')
50+
.pipe(uglify())
51+
.pipe(rename({suffix: '.min'}))
52+
.pipe(gulp.dest('dist/js'));
53+
54+
gulp.src('src/jquery.atwho.css').pipe(gulp.dest('dist/css'))
55+
gulp.src('dist/css/' + name + '.css')
56+
.pipe(cssmin())
57+
.pipe(rename({suffix: '.min'}))
58+
.pipe(gulp.dest('dist/css'));
559
});
60+
61+
62+
gulp.task('jasmine', function () {
63+
gulp.src('spec/build/javascripts/*.js')
64+
.pipe(jasmine({
65+
integration: true,
66+
vendor: [
67+
'bower_components/jquery/dist/jquery.js',
68+
'bower_components/Caret.js/src/*.js',
69+
'bower_components/jasmine-jquery/lib/jasmine-jquery.js',
70+
'spec/build/spec_helper.js',
71+
'spec/helpers/*.js'
72+
],
73+
74+
}));
75+
});
76+
77+
gulp.task('compile', ['coffee', 'umd', 'concat']);
78+
gulp.task('test', ['compile', 'jasmine']);
79+
gulp.task('default', ['compile', 'compress']);

package.json

+16-13
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@
88
"homepage": "http://ichord.github.com/At.js",
99
"license": "MIT",
1010
"version": "1.4.0",
11+
"repository" : {
12+
"type" : "git",
13+
"url" : "https://github.com/ichord/At.js"
14+
},
1115
"engines": {
1216
"node": ">= 0.6.0"
1317
},
1418
"scripts": {
15-
"test": "grunt test --verbose"
19+
"test": "gulp test --verbose"
1620
},
1721
"dependencies": {
1822
"jquery": "~1.7.0"
1923
},
2024
"devDependencies": {
21-
"grunt": "^0.4.5",
22-
"grunt-contrib-coffee": "^0.13.0",
23-
"grunt-contrib-concat": "^0.5.1",
24-
"grunt-contrib-connect": "^0.10.1",
25-
"grunt-contrib-copy": "^0.8.0",
26-
"grunt-contrib-cssmin": "^0.12.3",
27-
"grunt-contrib-jasmine": "^0.8.2",
28-
"grunt-contrib-uglify": "^0.9.1",
29-
"grunt-contrib-watch": "^0.6.1",
30-
"grunt-json-replace": "^0.1.2",
31-
"grunt-umd": "^2.3.3",
32-
"gulp": "^3.9.0"
25+
"gulp": "^3.9.0",
26+
"gulp-coffee": "^2.3.1",
27+
"gulp-concat": "^2.6.0",
28+
"gulp-cssmin": "^0.1.7",
29+
"gulp-jasmine": "^2.2.1",
30+
"gulp-jasmine-phantom": "^2.0.1",
31+
"gulp-rename": "^1.2.2",
32+
"gulp-uglify": "^1.5.1",
33+
"gulp-umd": "^0.2.0",
34+
"gulp-util": "^3.0.7",
35+
"umd-templates": "0.0.3"
3336
},
3437
"spm": {
3538
"main": "dist/js/jquery.atwho.js",

0 commit comments

Comments
 (0)