Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow integration #221

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ To get a nice Ionic styled list item wrap your content in a `ionItem` block temp

#### Path and Link Examples

Meteor uses Iron:Router. Most are familiar with Iron:Router's [pathFor](https://github.com/EventedMind/iron-router/blob/devel/Guide.md#pathfor) and [urlFor](https://github.com/EventedMind/iron-router/blob/devel/Guide.md#urlfor) helpers. Meteoric lets you tap into those helpers from within `ionItem` or ignore them, the choice is yours.
Meteor uses Iron:FlowRouter. Most are familiar with Iron:FlowRouter's [pathFor](https://github.com/EventedMind/iron-router/blob/devel/Guide.md#pathfor) and [urlFor](https://github.com/EventedMind/iron-router/blob/devel/Guide.md#urlfor) helpers. Meteoric lets you tap into those helpers from within `ionItem` or ignore them, the choice is yours.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As flow-router doesn't provides these methods natively, the current option seems to be @arillo's meteor-flow-router-helpers.


To call IR's `pathFor` you would specify your route in the `path` attribute.

Expand Down Expand Up @@ -314,7 +314,7 @@ Lastly you can also pass a raw url by including the `href` attribute.
{{/ionList}}
```

**IronRouter's pathFor href**
**IronFlowRouter's pathFor href**

```
{{! href="/item/details/jkh34k234h?parentId=hkjh45j43k3#reviews" }}
Expand All @@ -329,7 +329,7 @@ Lastly you can also pass a raw url by including the `href` attribute.
{{/ionList}}
```

**IronRouter's urlFor href**
**IronFlowRouter's urlFor href**

```
{{! href="http://www.example.com/item/details?parentId=hkjh45j43k3" }}
Expand Down
2 changes: 1 addition & 1 deletion components/ionBody/ionBody.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="ionBody">
<div class="ionic-body {{platformClasses}}">
{{> UI.contentBlock}}
{{> Template.contentBlock}}
</div>
</template>
2 changes: 1 addition & 1 deletion components/ionContent/ionContent.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template name="ionContent">
<div class="scroll-content ionic-scroll">
<div class="{{classes}}">
{{> UI.contentBlock}}
{{> Template.contentBlock}}
</div>
</div>
</template>
2 changes: 1 addition & 1 deletion components/ionFooterBar/ionFooterBar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="ionFooterBar">
<div class="{{classes}}">
{{> UI.contentBlock}}
{{> Template.contentBlock}}
</div>
</template>
2 changes: 1 addition & 1 deletion components/ionHeaderBar/ionHeaderBar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="ionHeaderBar">
<div class="{{classes}}">
{{> UI.contentBlock}}
{{> Template.contentBlock}}
</div>
</template>
6 changes: 3 additions & 3 deletions components/ionItem/ionItem.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template name="ionItem">
{{#if isAnchor}}
<a class="{{itemClasses}}" href="{{url}}" target="{{target}}">
{{> UI.contentBlock}}
{{> Template.contentBlock}}
</a>
{{else}}
<div class="{{itemClasses}}">
{{> UI.contentBlock}}
<div class="{{itemClasses}}" {{attrs}}>
{{> Template.contentBlock}}
</div>
{{/if}}
</template>
2 changes: 1 addition & 1 deletion components/ionItem/ionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Template.ionItem.helpers({
}

} else {
return Router.routes[path].path(Template.parentData(1));
return FlowRouter.path(path);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions components/ionNavBackButton/ionNavBackButton.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
IonScrollPositions = {};

Router.onStop(function () {
/*
FlowRouter.onStop(function () {
IonScrollPositions[this.route.path(this.params)] = $('.overflow-scroll').scrollTop();
});
});*/

Template.ionNavBackButton.events({
'click': function (event, template) {
$('[data-nav-container]').addClass('nav-view-direction-back');
$('[data-navbar-container]').addClass('nav-bar-direction-back');

if (template.backUrl) {
Router.go(template.backUrl);
FlowRouter.go(template.backUrl);
} else {
window.history.back();
}
Expand All @@ -31,7 +31,7 @@ Template.ionNavBackButton.rendered = function () {
}

if (this.data.path) {
backRoute = Router.routes[this.data.path]
backRoute = FlowRouter.routes[this.data.path]
if (!backRoute) {
console.warn("back to nonexistent route: ", this.data.path);
return;
Expand Down
6 changes: 3 additions & 3 deletions components/ionNavBar/ionNavBar.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template name="ionNavBar">
<div class="{{classes}} nav-bar-block nav-bar-transition-{{transition}} nav-bar-direction-forward" data-navbar-container>
{{> yield "headerButtonLeft"}}
{{> yield "headerTitle"}}
{{> yield "headerButtonRight"}}
{{> Template.dynamic template=headerButtonLeft}}
{{> Template.dynamic template=headerTitle}}
{{> Template.dynamic template=headerButtonRight}}
</div>
</template>
4 changes: 2 additions & 2 deletions components/ionNavView/ionNavView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Template.ionNavView.created = function () {
}
};

Template.ionNavView.rendered = function () {
Template.ionNavView.onRendered(function () {
var template = this;

this.find('[data-nav-container]')._uihooks = {
Expand Down Expand Up @@ -64,7 +64,7 @@ Template.ionNavView.rendered = function () {
}, template.transitionDuration);
}
};
};
});

Template.ionNavView.helpers({
transition: function () {
Expand Down
2 changes: 1 addition & 1 deletion components/ionSlideBox/ionSlideBox.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="ionSlideBox">
<div class="ion-slide-box">
{{> UI.contentBlock}}
{{> Template.contentBlock}}
</div>
</template>
2 changes: 1 addition & 1 deletion components/ionSubheaderBar/ionSubheaderBar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="ionSubheaderBar">
<div class="{{classes}}">
{{> UI.contentBlock}}
{{> Template.contentBlock}}
</div>
</template>
13 changes: 9 additions & 4 deletions components/ionTab/ionTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ Template.ionTab.helpers({
return this.href;
}

if (this.path && Router.routes[this.path]) {
return Router.routes[this.path].path(Template.parentData(1));
var routeExists =_.reject(FlowRouter._routes, function(route) {
return route.path === this.path;
});
// TODO: fix this syntax
if (this.path && routeExists.length) {
return this.path;
}
},

Expand All @@ -42,8 +46,9 @@ Template.ionTab.helpers({
// The initial case where there is no localStorage value and
// no session variable has been set, this attempts to set the correct tab
// to active based on the router
var route = Router.routes[this.path];
if(route && route.path(Template.parentData(1)) === ionTabCurrent){
FlowRouter.watchPathChange();
var route = FlowRouter.current();
if(route && route.path === this.path){
return 'active';
}
},
Expand Down
14 changes: 7 additions & 7 deletions components/ionTabs/ionTabs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Template.ionTabs.created = function () {
Template.ionTabs.onCreated(function () {
this.data = this.data || {};
};
});

Template.ionTabs.rendered = function () {
Template.ionTabs.onRendered(function () {
if ((this.data.class && this.data.class === 'tabs-top') || this.data.style === 'android') {
Session.set('hasTabsTop', true);
} else {
Expand All @@ -11,17 +11,17 @@ Template.ionTabs.rendered = function () {

this.$('.tabs').children().each(function() {
var href = $(this).attr('href');
var current = Router.current().location.get().path;
var current = FlowRouter.current().path;
if(href === current){
Session.set('ionTab.current', href);
}
});
};
});

Template.ionTabs.destroyed = function () {
Template.ionTabs.onDestroyed(function () {
Session.set('hasTabs', false);
Session.set('hasTabsTop', false);
};
});

Template.ionTabs.helpers({
classes: function () {
Expand Down
12 changes: 7 additions & 5 deletions components/ionView/ionView.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template name="ionView">
{{#if title}}
{{#contentFor "headerTitle"}}
<h1 class="title">{{title}}</h1>
{{/contentFor}}
{{#if data.title}}
{{> headerTitle title=data.title}}
{{/if}}

<div class="{{classes}}">
{{> UI.contentBlock}}
{{> Template.contentBlock}}
</div>
</template>

<template name="headerTitle">
<h1 class="title">{{title}}</h1>
</template>
7 changes: 4 additions & 3 deletions components/ionView/ionView.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Template.ionView.rendered = function () {
Template.ionView.onRendered(function () {
// Reset our transition preference
IonNavigation.skipTransitions = false;

// Reset our scroll position
var routePath = Router.current().route.path(Router.current().params);
var routePath = FlowRouter.current().path;

if(IonScrollPositions[routePath]) {
$('.overflow-scroll').scrollTop(IonScrollPositions[routePath]);
delete IonScrollPositions[routePath];
}
};
});

Template.ionView.helpers({
classes: function () {
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Cordova.depends({

Package.onUse(function(api) {
api.versionsFrom("1.0");
api.use(["templating", "underscore", "fastclick", "iron:router@1.0.0", "tracker", "session"], "client");
api.use(["templating", "underscore", "fastclick", "meteorhacks:flow-router@1.9.0", "tracker", "session"], "client");

api.addFiles([
"vendor/snap.js",
Expand Down