mirror of
https://github.com/donl/meteor-ionic.git
synced 2026-06-30 06:12:08 -06:00
add some platform specific configuration
This commit is contained in:
parent
140b53c734
commit
39e03979b9
7 changed files with 79 additions and 32 deletions
|
|
@ -1,17 +1,21 @@
|
|||
isIOS = function () {
|
||||
return !!navigator.userAgent.match(/iPad/i) || !!navigator.userAgent.match(/iPhone/i) || !!navigator.userAgent.match(/iPod/i);
|
||||
};
|
||||
Platform = {
|
||||
isIOS: function () {
|
||||
return (!!navigator.userAgent.match(/iPad/i) || !!navigator.userAgent.match(/iPhone/i) || !!navigator.userAgent.match(/iPod/i))
|
||||
|| Session.get('platformOverride') === 'iOS';
|
||||
},
|
||||
|
||||
isAndroid = function () {
|
||||
return navigator.userAgent.indexOf('Android') > 0;
|
||||
isAndroid: function () {
|
||||
return navigator.userAgent.indexOf('Android') > 0
|
||||
|| Session.get('platformOverride') === 'Android';
|
||||
}
|
||||
};
|
||||
|
||||
Template.registerHelper('isIOS', function () {
|
||||
return isIOS();
|
||||
return Platform.isIOS();
|
||||
});
|
||||
|
||||
Template.registerHelper('isAndroid', function () {
|
||||
return isAndroid();
|
||||
return Platform.isAndroid();
|
||||
});
|
||||
|
||||
Template.ionBody.helpers({
|
||||
|
|
@ -24,10 +28,10 @@ Template.ionBody.helpers({
|
|||
if (Meteor.isClient) {
|
||||
classes.push('platform-web');
|
||||
}
|
||||
if (Meteor.isCordova && isIOS()) {
|
||||
if ((Meteor.isCordova && Platform.isIOS()) || Session.get('platformOverride') === 'iOS') {
|
||||
classes.push('platform-ios');
|
||||
}
|
||||
if (Meteor.isCordova && isAndroid()) {
|
||||
if ((Meteor.isCordova && Platform.isAndroid()) || Session.get('platformOverride') === 'Android') {
|
||||
classes.push('platform-android');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ Template.ionContent.helpers({
|
|||
classes.push('has-tabs');
|
||||
}
|
||||
|
||||
if (Session.get('hasTabsTop')) {
|
||||
classes.push('has-tabs-top');
|
||||
}
|
||||
|
||||
if (Session.get('hasFooter')) {
|
||||
classes.push('has-footer');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,25 @@
|
|||
Template.ionHeaderBar.rendered = function () {
|
||||
Session.set('hasHeader', true);
|
||||
|
||||
var align = this.alignTitle || 'center';
|
||||
var $title = this.$('.title');
|
||||
function alignTitle () {
|
||||
var align = this.alignTitle || 'center';
|
||||
var $title = this.$('.title');
|
||||
|
||||
if (align === 'center') {
|
||||
$title.addClass('title-center');
|
||||
} else if (align === 'left') {
|
||||
$title.addClass('title-left');
|
||||
} else if (align === 'right') {
|
||||
$title.addClass('title-right');
|
||||
}
|
||||
if (align === 'center' && Platform.isAndroid()) {
|
||||
$title.addClass('title-left');
|
||||
return;
|
||||
}
|
||||
|
||||
if (align === 'center') {
|
||||
$title.addClass('title-center');
|
||||
} else if (align === 'left') {
|
||||
$title.addClass('title-left');
|
||||
} else if (align === 'right') {
|
||||
$title.addClass('title-right');
|
||||
}
|
||||
};
|
||||
|
||||
alignTitle.call(this);
|
||||
};
|
||||
|
||||
Template.ionHeaderBar.destroyed = function () {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Template.ionNavBar.created = function () {
|
||||
if (isAndroid()) {
|
||||
if (Platform.isAndroid()) {
|
||||
this.transition = 'android';
|
||||
} else {
|
||||
this.transition = 'ios';
|
||||
|
|
@ -20,18 +20,31 @@ Template.ionNavBar.created = function () {
|
|||
Template.ionNavBar.rendered = function () {
|
||||
Session.set('hasHeader', true);
|
||||
|
||||
var align = this.alignTitle || 'center';
|
||||
var $title = this.$('.title');
|
||||
function alignTitle () {
|
||||
var align = this.alignTitle || 'center';
|
||||
var $title = this.$('.title');
|
||||
|
||||
if (align === 'center') {
|
||||
$title.addClass('title-center');
|
||||
} else if (align === 'left') {
|
||||
$title.addClass('title-left');
|
||||
} else if (align === 'right') {
|
||||
$title.addClass('title-right');
|
||||
}
|
||||
if (align === 'center' && Platform.isAndroid()) {
|
||||
$title.addClass('title-left');
|
||||
return;
|
||||
}
|
||||
|
||||
if (align === 'center') {
|
||||
$title.addClass('title-center');
|
||||
} else if (align === 'left') {
|
||||
$title.addClass('title-left');
|
||||
} else if (align === 'right') {
|
||||
$title.addClass('title-right');
|
||||
}
|
||||
};
|
||||
|
||||
function positionTitle () {
|
||||
|
||||
};
|
||||
|
||||
alignTitle.call(this);
|
||||
positionTitle.call(this);
|
||||
|
||||
// Animate the title
|
||||
var template = this;
|
||||
this.find('[data-navbar-container]')._uihooks = {
|
||||
insertElement: function(node, next) {
|
||||
|
|
@ -44,6 +57,9 @@ Template.ionNavBar.rendered = function () {
|
|||
|
||||
if ($node.hasClass('title')) {
|
||||
$node.insertBefore(next).addClass('title-entering title-stage');
|
||||
|
||||
alignTitle.call(template);
|
||||
|
||||
Meteor.setTimeout(function() {
|
||||
$node.removeClass('title-stage').addClass('title-active');
|
||||
}, 16);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
Template.ionNavView.created = function () {
|
||||
Session.setDefault('ionNavDirection', 'forward');
|
||||
|
||||
if (isAndroid()) {
|
||||
if (Platform.isAndroid()) {
|
||||
this.transition = 'android';
|
||||
} else {
|
||||
this.transition = 'ios';
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
Template.ionTabs.rendered = function () {
|
||||
Session.set('hasTabs', true);
|
||||
if (Platform.isAndroid()) {
|
||||
Session.set('hasTabsTop', true);
|
||||
}
|
||||
if (this.class && this.class === 'tabs-top') {
|
||||
Session.set('hasTabsTop', true);
|
||||
} else {
|
||||
Session.set('hasTabs', true);
|
||||
}
|
||||
};
|
||||
|
||||
Template.ionTabs.destroyed = function () {
|
||||
Session.set('hasTabs', false);
|
||||
Session.set('hasTabsTop', false);
|
||||
};
|
||||
|
||||
Template.ionTabs.helpers({
|
||||
|
|
@ -12,6 +20,10 @@ Template.ionTabs.helpers({
|
|||
|
||||
if (this.class) {
|
||||
classes.push(this.class);
|
||||
}
|
||||
|
||||
if (Platform.isAndroid()) {
|
||||
classes.push('tabs-top tabs-striped tabs-icon-left');
|
||||
} else {
|
||||
classes.push('tabs-icon-top');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
Package.describe({
|
||||
name: "meteoric:ionic",
|
||||
summary: "Ionic components for Meteor. No Angular!",
|
||||
version: "0.1.4",
|
||||
version: "0.1.5",
|
||||
git: "https://github.com/meteoric/meteor-ionic.git"
|
||||
});
|
||||
|
||||
|
|
@ -94,6 +94,8 @@ Package.onUse(function(api) {
|
|||
"components/ionView/ionView.js"
|
||||
], "client");
|
||||
|
||||
api.export("Platform");
|
||||
|
||||
api.export("IonActionSheet");
|
||||
api.export("IonBackdrop");
|
||||
api.export("IonLoading");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue