fix traceur not showing errors

This commit is contained in:
Andrew
2015-03-18 16:55:22 -05:00
parent 5a5ead5db6
commit c96c713574
12 changed files with 191 additions and 26 deletions

View File

@@ -76,21 +76,20 @@ gulp.task('playgroundFiles', function() {
gulp.task('playgroundJs', function() {
return gulp.src(config.src.playgroundJs)
.pipe(traceurCompile())
.pipe(rename({extname: ''})) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
.pipe(plumber())
.pipe(traceur({
modules: 'instantiate',
moduleName: true,
annotations: true,
types: true
}))
.pipe(rename({extname: '.js'})) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
.pipe(gulp.dest(config.dist));
});
function traceurCompile() {
return lazypipe()
.pipe(rename, {extname: ''}) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
.pipe(plumber)
.pipe(traceur, {
modules: 'instantiate',
moduleName: true,
annotations: true,
types: true
})
.pipe(rename, {extname: '.js'}) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
();
}
gulp.task('js', function () {
@@ -99,7 +98,15 @@ gulp.task('js', function () {
// Forces the files to register themselves with 'ionic' prefix
file.dirname = 'ionic/' + file.dirname;
}))
.pipe(traceurCompile())
.pipe(rename({extname: ''})) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
.pipe(plumber())
.pipe(traceur({
modules: 'instantiate',
moduleName: true,
annotations: true,
types: true
}))
.pipe(rename({extname: '.js'})) //hack, see: https://github.com/sindresorhus/gulp-traceur/issues/54
// compiled js files in playground go to the playground root, everything else goes in /ionic
.pipe(gulp.dest('dist'));
});

View File

@@ -2,13 +2,14 @@ import {bootstrap} from 'angular2/core';
import {Component, Template} from 'angular2/angular2';
import {Tabbar} from 'ionic/components/tabbar/tabbar';
import {Modal} from 'ionic/components/modal/modal';
import {SideMenu, SideMenuParent} from 'ionic/components/sidemenu/sidemenu';
import 'ionic/components/tabbar/mixins/android/android-tabbar';
@Component({ selector: '[playground-main]' })
@Template({
url: 'main.html',
directives: [Tabbar, Modal]
directives: [Tabbar, Modal, SideMenu, SideMenuParent]
})
class PlaygroundMain {
constructor() {

View File

@@ -19,4 +19,5 @@
@import "../button/button";
@import "../tabbar/tabbar";
@import "../modal/modal";
@import "../sidemenu/sidemenu";

View File

@@ -1,7 +1,65 @@
import {Component, Template} from 'angular2/angular2';
import {ViewGroup} from '../view-group';
import {Component, Template, Inject, Parent, NgElement} from 'angular2/angular2';
import {Ion} from '../ion';
// import {EdgeDragGesture} from '../../core/gestures/edge-drag-gesture';
class Sidemenu extends ViewGroup {
constructor() {
@Component({
selector: 'ion-side-menu',
bind: {
side: 'side'
}
})
@Template({
inline: `<content></content>`
})
export class SideMenu extends Ion {
constructor(
@Parent() sideMenuParent: SideMenuParent,
@NgElement() element: NgElement
) {
this.el = element;
// this.gesture = new EdgeDragGesture(sideMenuParent.el.domElement, this);
this._drag = {};
super();
}
onDragStart(ev) {
this._drag = {
width: this.el.domElement.offsetWidth
};
this.el.domElement.classList.add('no-animate');
}
onDrag(ev) {
var pos = this._drag.pos = Math.max(0, Math.min(ev.center.x, this._drag.width));
this.el.domElement.style.transform = 'translate3d(0,' + pos + 'px,0)';
}
onDragEnd(ev) {
var { pos, width } = this._drag;
this.el.domElement.style.transform = '';
if (pos < width / 2) {
this.close();
} else if (pos > width / 2) {
this.open();
}
this.el.domElement.style.transform = '';
this.el.domElement.classList.remove('no-animate');
this._drag = null;
}
open() {
this.el.domElement.classList.add('open');
}
close() {
this.el.domElement.classList.remove('open');
}
}
@Component({
selector: 'ion-side-menu-parent'
})
@Template({
inline: '<content></content>'
})
export class SideMenuParent extends Ion {
constructor(@NgElement() element: NgElement) {
this.el = element;
super();
}
}

View File

@@ -0,0 +1,20 @@
ion-side-menu {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 304px;
background: rgba(255,0,0,0.5);
border-right: 1px solid black;
transition: transform 0.3s;
transform: translate3d(0, -304px, 0);
&.open {
transform: translate3d(0,0,0);
}
&.no-animate {
transition-duration: 0s;
}
}

View File

@@ -5,13 +5,5 @@ import {TabbarConfig} from '../../tabbar';
TabbarConfig.platform('android')
.template('./android-template.html')
.mixin(function(tabbar) {
// Draggable(tabbar)
// tabbarInstance.setAsHeader()
tabbar.extend({
press() {
alert('pressing from android mixin');
}
});
});

View File

@@ -13,7 +13,9 @@ export var TabbarConfig = new IonConfigService();
services: [TabbarConfig]
})
@Template({
inline: `<button (click)="press()">Tabbar: {{title}} {{$config.id}}</button>`
inline: `<button (click)="press()">
Tabbar: {{title}} {{$config.id}}
</button>`
})
export class Tabbar extends Ion {
constructor(

View File

@@ -0,0 +1,31 @@
import {Gesture} from './gesture';
var noop = function() {};
class DragGesture extends Gesture {
// constructor(element, opts = {}) {
// super(element, opts);
// this.onDrag = opts.onDrag;
// this.onDragStart = opts.onDragStart;
// this.onDragEnd = opts.onDragEnd;
// }
// listen() {
// super.listen();
// this.hammertime.on('dragstart', this._onDragStart.bind(this));
// this.hammertime.on('drag', this._onDrag.bind(this));
// this.hammertime.on('dragend', this._onDragEnd.bind(this));
// }
// unlisten() {
// super.unlisten();
// this.hammertime.destroy();
// }
// _onDragStart(ev) {
// (this.onDragStart || noop)(ev);
// }
// _onDrag(ev) {
// (this.onDrag || noop)(ev);
// }
// _onDragEnd(ev) {
// (this.onDragEnd || noop)(ev);
// }
}

View File

@@ -0,0 +1,17 @@
import {DragGesture} from './drag-gesture';
class EdgeDragGesture extends DragGesture {
// constructor(element, opts = { edge = 'left', buffer = 25 } = {}) {
// super(element, opts);
// }
// _onDragStart(ev) {
// var { buffer, edge } = this._options;
// var { gesture } = ev;
// if (edge === 'left' && gesture.center.x > buffer) return;
// if (edge === 'top' && gesture.center.y > buffer) return;
// if (edge === 'right' && gesture.center.y < window.innerWidth - buffer) return;
// if (edge === 'bottom' && gesture.center.y < window.innerHeight - buffer) return;
// super._onDragStart(ev);
// }
}

View File

View File

@@ -0,0 +1,37 @@
export class Gesture {
// constructor(element, opts = {}) {
// this.element = element;
// this._options = opts;
// }
// options(opts = {}) {
// extend(this._options, opts);
// }
// listen() {
// this.hammertime = Hammer(element, this._options);
// }
// unlisten() {
// this.hammertime.destroy();
// this.hammertime = null;
// }
// destroy() {
// this.hammertime.destroy();
// }
}
// TODO make a utils.js
function extend() {
for (var i = 0, ii = arguments.length; i < ii; i++) {
var obj = arguments[i];
if (obj) {
var keys = Object.keys(obj);
for (var j = 0, jj = keys.length; j < jj; j++) {
var key = keys[j];
if (!ILLEGAL_ASSIGN_FIELDS[key]) {
this[key] = obj[key];
}
}
}
}
}

View File

@@ -1 +0,0 @@