make ionLoading parameters optional. fixes #22

This commit is contained in:
Nick Wientge 2015-01-17 17:29:30 -08:00
parent 6985ddbb7f
commit 0b0d033fd1

View file

@ -1,15 +1,18 @@
IonLoading = {
show: function (options) {
show: function (userOptions) {
IonBackdrop.retain();
$('.backdrop').addClass('backdrop-loading');
var delay = options.delay || 0;
var duration = options.duration;
var customTemplate = options.template;
var userOptions = userOptions || {};
var options = _.extend({
delay: 0,
duration: null,
customTemplate: null
}, userOptions);
Meteor.setTimeout(function () {
this.template = Template['ionLoading'];
this.view = Blaze.renderWithData(this.template, {template: customTemplate}, $('.ionic-body').get(0));
this.view = Blaze.renderWithData(this.template, {template: options.customTemplate}, $('.ionic-body').get(0));
var $loadingEl = $(this.view.firstNode());
$loadingEl.addClass('visible');
@ -17,12 +20,12 @@ IonLoading = {
Meteor.setTimeout(function () {
$loadingEl.addClass('active');
}, 10);
}.bind(this), delay);
}.bind(this), options.delay);
if (duration) {
if (options.duration) {
Meteor.setTimeout(function () {
this.hide();
}.bind(this), duration);
}.bind(this), options.duration);
}
},