Skip to content

Commit

Permalink
complete gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
ichord committed Jan 23, 2016
1 parent 3590599 commit a119e33
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 58 deletions.
87 changes: 45 additions & 42 deletions dist/js/jquery.atwho.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
/*! jquery.atwho - v1.4.0 %>
* Copyright (c) 2016 chord.luo <[email protected]>;
* homepage: http://ichord.github.com/At.js
* Licensed MIT
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define(["jquery"], function (a0) {
return (factory(a0));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("jquery"));
} else {
factory(jQuery);
}
}(this, function (jquery) {

var $, Api, App, Controller, DEFAULT_CALLBACKS, EditableController, KEY_CODE, Model, TextareaController, View,
slice = [].slice,
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; },
hasProp = {}.hasOwnProperty;

$ = jquery;
(function(factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports === 'object') {
factory(require('jquery'));
} else {
factory(jQuery);
}
}(function($) {
var App;

App = (function() {
function App(inputor) {
Expand All @@ -45,7 +28,7 @@ App = (function() {
};

App.prototype.setupRootElement = function(iframe, asRoot) {
var error;
var error, error1;
if (asRoot == null) {
asRoot = false;
}
Expand All @@ -58,8 +41,8 @@ App = (function() {
this.window = this.document.defaultView || this.document.parentWindow;
try {
this.iframe = this.window.frameElement;
} catch (_error) {
error = _error;
} catch (error1) {
error = error1;
this.iframe = null;
if ($.fn.atwho.debug) {
throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n" + error);
Expand Down Expand Up @@ -269,13 +252,16 @@ App = (function() {

})();

var Controller,
slice = [].slice;

Controller = (function() {
Controller.prototype.uid = function() {
return (Math.random().toString(16) + "000000000").substr(2, 8) + (new Date().getTime());
};

function Controller(app1, at1) {
this.app = app1;
function Controller(app, at1) {
this.app = app;
this.at = at1;
this.$inputor = this.app.$inputor;
this.id = this.$inputor[0].id || this.uid();
Expand Down Expand Up @@ -305,12 +291,12 @@ Controller = (function() {
};

Controller.prototype.callDefault = function() {
var args, error, funcName;
var args, error, error1, funcName;
funcName = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
try {
return DEFAULT_CALLBACKS[funcName].apply(this, args);
} catch (_error) {
error = _error;
} catch (error1) {
error = error1;
return $.error(error + " Or maybe At.js doesn't have function " + funcName);
}
};
Expand All @@ -331,11 +317,11 @@ Controller = (function() {
};

Controller.prototype.getOpt = function(at, default_value) {
var e;
var e, error1;
try {
return this.setting[at];
} catch (_error) {
e = _error;
} catch (error1) {
e = error1;
return null;
}
};
Expand Down Expand Up @@ -452,6 +438,10 @@ Controller = (function() {

})();

var TextareaController,
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; },
hasProp = {}.hasOwnProperty;

TextareaController = (function(superClass) {
extend(TextareaController, superClass);

Expand Down Expand Up @@ -530,6 +520,10 @@ TextareaController = (function(superClass) {

})(Controller);

var EditableController,
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; },
hasProp = {}.hasOwnProperty;

EditableController = (function(superClass) {
extend(EditableController, superClass);

Expand Down Expand Up @@ -726,6 +720,8 @@ EditableController = (function(superClass) {

})(Controller);

var Model;

Model = (function() {
function Model(context) {
this.context = context;
Expand Down Expand Up @@ -790,6 +786,8 @@ Model = (function() {

})();

var View;

View = (function() {
function View(context) {
this.context = context;
Expand Down Expand Up @@ -986,6 +984,8 @@ View = (function() {

})();

var DEFAULT_CALLBACKS, KEY_CODE;

KEY_CODE = {
DOWN: 40,
UP: 38,
Expand Down Expand Up @@ -1055,7 +1055,7 @@ DEFAULT_CALLBACKS = {
});
},
tplEval: function(tpl, map) {
var error, template;
var error, error1, template;
template = tpl;
try {
if (typeof tpl !== 'string') {
Expand All @@ -1064,8 +1064,8 @@ DEFAULT_CALLBACKS = {
return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
return map[key];
});
} catch (_error) {
error = _error;
} catch (error1) {
error = error1;
return "";
}
},
Expand All @@ -1088,6 +1088,8 @@ DEFAULT_CALLBACKS = {
afterMatchFailed: function(at, el) {}
};

var Api;

Api = {
load: function(at, data) {
var c;
Expand Down Expand Up @@ -1174,4 +1176,5 @@ $.fn.atwho["default"] = {
$.fn.atwho.debug = false;


}));
$.fn.Jquery.atwho = Jquery.atwho;
}));
80 changes: 77 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,79 @@
var gulp = require('gulp');
var gulp = require('gulp'),
coffee = require('gulp-coffee'),
concat = require('gulp-concat'),
umd = require('gulp-umd'),
umdTempl = require('umd-templates'),
uglify = require('gulp-uglify'),
rename = require("gulp-rename"),
cssmin = require('gulp-cssmin'),
jasmine = require('gulp-jasmine-phantom'),
util = require('gulp-util');

gulp.task('default', function() {
// place code for your default task here
var name = 'jquery.atwho';

gulp.task('coffee', function() {
gulp.src('src/*.coffee')
.pipe(coffee({bare: true}).on('error', util.log))
.pipe(gulp.dest('./build/js'));

gulp.src('spec/**/*.coffee')
.pipe(coffee({bare: true}).on('error', util.log))
.pipe(gulp.dest('spec/build'))
});

gulp.task('concat', function() {
fileList = [
//'build/js/noConflict.js',
'build/js/app.js',
'build/js/controller.js',
'build/js/textareaController.js',
'build/js/editableController.js',
'build/js/model.js',
'build/js/view.js',
'build/js/default.js',
'build/js/api.js'
]
gulp.src(fileList)
.pipe(concat(name + ".js"))
.pipe(gulp.dest('build'));
});

gulp.task('umd', function() {
gulp.src('build/' + name + ".js")
.pipe(umd({
template: umdTempl.jqueryPluginCommonjs.path
})).pipe(gulp.dest('dist/js'));
});

gulp.task('compress', function() {
gulp.src('dist/js/' + name + '.js')
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/js'));

gulp.src('src/jquery.atwho.css').pipe(gulp.dest('dist/css'))
gulp.src('dist/css/' + name + '.css')
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/css'));
});


gulp.task('jasmine', function () {
gulp.src('spec/build/javascripts/*.js')
.pipe(jasmine({
integration: true,
vendor: [
'bower_components/jquery/dist/jquery.js',
'bower_components/Caret.js/src/*.js',
'bower_components/jasmine-jquery/lib/jasmine-jquery.js',
'spec/build/spec_helper.js',
'spec/helpers/*.js'
],

}));
});

gulp.task('compile', ['coffee', 'umd', 'concat']);
gulp.task('test', ['compile', 'jasmine']);
gulp.task('default', ['compile', 'compress']);
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@
"homepage": "http://ichord.github.com/At.js",
"license": "MIT",
"version": "1.4.0",
"repository" : {
"type" : "git",
"url" : "https://github.com/ichord/At.js"
},
"engines": {
"node": ">= 0.6.0"
},
"scripts": {
"test": "grunt test --verbose"
"test": "gulp test --verbose"
},
"dependencies": {
"jquery": "~1.7.0"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-coffee": "^0.13.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-connect": "^0.10.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "^0.12.3",
"grunt-contrib-jasmine": "^0.8.2",
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-json-replace": "^0.1.2",
"grunt-umd": "^2.3.3",
"gulp": "^3.9.0"
"gulp": "^3.9.0",
"gulp-coffee": "^2.3.1",
"gulp-concat": "^2.6.0",
"gulp-cssmin": "^0.1.7",
"gulp-jasmine": "^2.2.1",
"gulp-jasmine-phantom": "^2.0.1",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.1",
"gulp-umd": "^0.2.0",
"gulp-util": "^3.0.7",
"umd-templates": "0.0.3"
},
"spm": {
"main": "dist/js/jquery.atwho.js",
Expand Down

0 comments on commit a119e33

Please sign in to comment.