add standard

This commit is contained in:
Andrew
2015-03-20 09:20:52 -05:00
parent 080a39fd90
commit 0cdfb10560
12 changed files with 113 additions and 44 deletions

View File

@ -3,6 +3,7 @@
- Run `gulp watch` to build, serve, and watch Ionic & playground
- Run `gulp karma-watch` while gulp watch is running to watch tests. Unit tests run on compiled files in dist.
- All test files must be suffixed with `_spec.js`.
#### Problems already

View File

@ -3,18 +3,20 @@
/////
var gulp = require('gulp');
var gulpif = require('gulp-if');
var del = require('del');
var karma = require('karma').server;
var buildConfig = require('./scripts/build/config');
var concat = require('gulp-concat');
var debug = require('gulp-debug');
var del = require('del');
var exec = require('gulp-exec');
var karma = require('karma').server;
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var traceur = require('gulp-traceur');
var lazypipe = require('lazypipe');
var sass = require('gulp-sass');
var shell = require('gulp-shell');
var traceur = require('gulp-traceur');
var wrap = require("gulp-wrap");
var config = require('./scripts/build/config');
var karma = require('karma').server;
gulp.task('default', ['js', 'html', 'sass', 'libs', 'playgroundJs', 'playgroundFiles']);
@ -22,20 +24,23 @@ gulp.task('watch', ['default'], function() {
var http = require('http');
var connect = require('connect');
var serveStatic = require('serve-static');
var open = require('open');
var port = 9000;
gulp.watch(config.src.html, ['html']);
gulp.watch(config.src.js, ['js']);
gulp.watch(config.src.scss, ['sass']);
gulp.watch(config.src.playgroundJs, ['playgroundJs']);
gulp.watch(config.src.playgroundFiles, ['playgroundFiles']);
gulp.watch(buildConfig.src.html, ['html']);
gulp.watch(buildConfig.src.js, ['js']);
gulp.watch(buildConfig.src.scss, ['sass']);
gulp.watch(buildConfig.src.playgroundJs, ['playgroundJs']);
gulp.watch(buildConfig.src.playgroundFiles, ['playgroundFiles']);
var app = connect().use(serveStatic(__dirname + '/' + config.dist)); // serve everything that is static
var app = connect().use(serveStatic(__dirname + '/' + buildConfig.dist)); // serve everything that is static
http.createServer(app).listen(port);
console.log('Serving `dist` on http://localhost:' + port);
});
gulp.task('lint', shell.task([
'./node_modules/.bin/standard'
]));
gulp.task('karma', function() {
return karma.start({ configFile: __dirname + '/scripts/test/karma.conf.js' });
});
@ -59,16 +64,16 @@ gulp.task('sass', function(done) {
});
gulp.task('clean', function(done) {
del([config.dist], done);
del([buildConfig.dist], done);
});
gulp.task('playgroundFiles', function() {
return gulp.src(config.src.playgroundFiles)
.pipe(gulp.dest(config.dist));
return gulp.src(buildConfig.src.playgroundFiles)
.pipe(gulp.dest(buildConfig.dist));
});
gulp.task('playgroundJs', function() {
return gulp.src(config.src.playgroundJs)
return gulp.src(buildConfig.src.playgroundJs)
.pipe(rename({extname: ''})) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
.pipe(plumber())
.pipe(traceur({
@ -78,7 +83,7 @@ gulp.task('playgroundJs', function() {
types: true
}))
.pipe(rename({extname: '.js'})) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
.pipe(gulp.dest(config.dist));
.pipe(gulp.dest(buildConfig.dist));
});
function traceurCompile() {
@ -86,7 +91,7 @@ function traceurCompile() {
();
}
gulp.task('js', function () {
return gulp.src(config.src.js)
return gulp.src(buildConfig.src.js)
.pipe(rename(function(file) {
// Forces the files to register themselves with 'ionic' prefix
file.dirname = 'ionic/' + file.dirname;
@ -106,12 +111,12 @@ gulp.task('js', function () {
gulp.task('html', function () {
// Don't do anything with html for now
// return gulp.src(config.src.html)
// .pipe(gulp.dest(config.dist));
// return gulp.src(buildConfig.src.html)
// .pipe(gulp.dest(buildConfig.dist));
});
gulp.task('libs', ['angular2'], function () {
return gulp.src(config.lib)
return gulp.src(buildConfig.lib)
.pipe(gulp.dest('dist/lib'));
});

View File

@ -1,6 +1,12 @@
{
"name": "ionic2",
"version": "0.0.0",
"standard": {
"ignore": [
"dist/**/*",
"scripts/**/*"
]
},
"devDependencies": {
"connect": "^3.3.4",
"del": "~1.1.1",
@ -8,14 +14,16 @@
"gulp-concat": "~2.5.0",
"gulp-debug": "~2.0.1",
"gulp-if": "^1.2.5",
"gulp-eslint": "^0.7.0",
"gulp-exec": "^2.1.1",
"gulp-jscs": "^1.4.0",
"gulp-plumber": "^1.0.0",
"gulp-rename": "~1.2.0",
"gulp-sass": "^1.3.3",
"gulp-shell": "^0.4.0",
"gulp-traceur": "0.16.*",
"gulp-wrap": "~0.11.0",
"karma": "^0.12.31",
"lazypipe": "^0.2.2",
"open": "0.0.5",
"serve-static": "~1.8.1",
"through2": "~0.6.3"
},
@ -28,6 +36,7 @@
"karma-jasmine": "^0.3.5",
"systemjs": "~0.11.0",
"traceur": "0.0.87",
"zone.js": "0.4.1"
"zone.js": "0.4.1",
"standard": "driftyco/standard#master"
}
}

View File

@ -1,7 +1,5 @@
import {bootstrap} from 'angular2/core';
import {Component, Template} from 'angular2/angular2';
import {Modal} from 'ionic/components/modal/modal';
import {Switch} from 'ionic/components/switch/switch';
import {SideMenu, SideMenuParent} from 'ionic/components';
// import 'ionic/components/tabbar/mixins/android/android-tabbar';
@ -15,10 +13,6 @@ class PlaygroundMain {
constructor() {
console.log('Playground Start')
}
showModal() {
Modal.show()
}
}
bootstrap(PlaygroundMain)

View File

@ -3,7 +3,6 @@ import {Component, Template} from 'angular2/angular2';
import {View, Content} from 'ionic/components/view/view';
import {Tabs, Tab} from 'ionic/components/tabs/tabs';
@Component({ selector: '[ion-app]' })
@Template({
url: 'main.html',

View File

@ -1,3 +1,2 @@
export * from './components/sidemenu/sidemenu';
import './components/sidemenu/behaviors/direction/direction';

View File

@ -6,17 +6,18 @@ import * as util from '../../util';
export var sideMenuConfig = new IonConfig();
// TODO defaults or bindings?
sideMenuConfig.defaults({
side: 'left',
dragThreshold: '50'
});
@Component({
selector: 'ion-side-menu'
// bind: {
// side: 'side',
// dragThreshold: 'dragThreshold'
// },
selector: 'ion-side-menu',
bind: {
side: 'side',
dragThreshold: 'dragThreshold'
},
})
@Template({
inline: `<content></content>`
@ -26,7 +27,6 @@ export class SideMenu extends Ion {
@Parent() sideMenuParent: SideMenuParent,
@NgElement() element: NgElement
) {
debugger;
this.domElement = element.domElement;
this._drag = {};
@ -68,7 +68,6 @@ export class SideMenu extends Ion {
});
}
onDrag(ev) {
console.log('ondrag');
if (!this._drag) return;
this.dragMethods.onDrag(this._drag, ev);
}

View File

@ -12,22 +12,18 @@ export class DragGesture extends Gesture {
}
listen() {
super.listen();
console.log('listening');
this.hammertime.on('panstart', ev => {
console.log('panstart');
if (this.onDragStart && this.onDragStart(ev) !== false) {
this.dragging = true;
}
});
this.hammertime.on('panmove', ev => {
console.log('panmove');
if (!this.dragging) return;
if (this.onDrag && this.onDrag(ev) === false) {
this.dragging = false;
}
});
this.hammertime.on('panend', ev => {
console.log('panend');
if (!this.dragging) return;
this.onDragEnd && this.onDragEnd(ev);
this.dragging = false;

View File

34
src/views/view-history.js Normal file
View File

@ -0,0 +1,34 @@
export class ViewHistory {
constructor() {
this._array = [];
}
indexOf(item) {
return this._array.indexOf(item);
}
push(item) {
return this._array.push(item);
}
pop() {
return this._array.pop();
}
popTo(index) {
var item = this._array[index];
if (index !== -1) {
this._array.length = index + 1;
}
return item;
}
peek(index) {
if (!arguments.length) index = this._array.length - 1;
return this._array[this._array.length - 1];
}
length() {
return this._array.length;
}
}

33
src/views/view.js Normal file
View File

@ -0,0 +1,33 @@
import * as util from '../util';
import {ViewHistory} from './view-history';
export class View extends ViewSwitcher {
constructor(el) {
super(el);
// A linear history of views that this switcher has gone
// through.
this.history = new ViewHistory();
this.currentChild = null;
}
setChild(view, options = {}) {
var direction = options.direction || 'forward';
var viewIndex = this.history.indexOf(view);
if (viewIndex !== -1) {
direction = 'back';
this.history.popTo(viewIndex);
} else {
this.history.push(view);
}
if (this.currentView) {
this.element.removeChild(this.currentView.element);
}
this.element.appendChild(view.element);
this.currentView = view.element;
}
}