diff --git a/components/ionActionSheet/ionActionSheet.html b/components/ionActionSheet/ionActionSheet.html new file mode 100644 index 0000000..52000d1 --- /dev/null +++ b/components/ionActionSheet/ionActionSheet.html @@ -0,0 +1,28 @@ + diff --git a/components/ionActionSheet/ionActionSheet.js b/components/ionActionSheet/ionActionSheet.js new file mode 100644 index 0000000..523acb4 --- /dev/null +++ b/components/ionActionSheet/ionActionSheet.js @@ -0,0 +1,71 @@ +IonActionSheet = { + transitionEndEvent: 'transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', + + show: function (options) { + this.template = Template.ionActionSheet; + + var buttons = []; + for (var i = 0; i < options.buttons.length; i++) { + var button = options.buttons[i]; + buttons.push({ + text: button.text, + index: i + }); + } + + var data = { + titleText: options.titleText, + destructiveText: options.destructiveText, + cancelText: options.cancelText, + buttons: buttons + }; + + this.view = Blaze.renderWithData(this.template, data, $('.ionic-body').get(0)); + $('body').addClass('action-sheet-open'); + + var $backdrop = $(this.view.firstNode()); + $backdrop.addClass('active'); + + var $wrapper = $backdrop.find('.action-sheet-wrapper'); + Meteor.setTimeout(function () { + $wrapper.addClass('action-sheet-up'); + }, 20); + }, + + close: function () { + var $backdrop = $(this.view.firstNode()); + $backdrop.removeClass('active'); + + var $wrapper = $backdrop.find('.action-sheet-wrapper'); + Meteor.setTimeout(function() { + $wrapper.removeClass('action-sheet-up'); + }.bind(this), 10); + + $wrapper.on(this.transitionEndEvent, function () { + $('body').removeClass('action-sheet-open'); + Blaze.remove(this.view); + }.bind(this)); + } +}; + +Template.ionActionSheet.events({ + // Handle clicking the backdrop + 'click': function (event, template) { + // if (event.target === ?) { + // IonActionSheet.close(); + // } + }, + + 'click [data-index]': function (event, template) { + IonActionSheet.close(); + }, + + 'click [data-destructive]': function (event, template) { + IonActionSheet.close(); + }, + + 'click [data-cancel]': function (event, template) { + IonActionSheet.close(); + } + +}); diff --git a/package.js b/package.js index ca67365..7261365 100644 --- a/package.js +++ b/package.js @@ -15,6 +15,9 @@ Package.onUse(function(api) { ], "client"); api.addFiles([ + "components/ionActionSheet/ionActionSheet.html", + "components/ionActionSheet/ionActionSheet.js", + "components/ionBody/ionBody.html", "components/ionBody/ionBody.js", @@ -70,6 +73,7 @@ Package.onUse(function(api) { "components/ionView/ionView.js" ], "client"); + api.export("IonActionSheet"); api.export("IonModal"); api.export("IonNavView"); }); diff --git a/showcase/client/templates/actionSheet/actionSheet.html b/showcase/client/templates/actionSheet/actionSheet.html index 1a80e24..e8a60f8 100644 --- a/showcase/client/templates/actionSheet/actionSheet.html +++ b/showcase/client/templates/actionSheet/actionSheet.html @@ -8,7 +8,9 @@ {{#ionContent}}
- Content goes here +
{{/ionContent}} diff --git a/showcase/client/templates/actionSheet/actionSheet.js b/showcase/client/templates/actionSheet/actionSheet.js new file mode 100644 index 0000000..0765329 --- /dev/null +++ b/showcase/client/templates/actionSheet/actionSheet.js @@ -0,0 +1,28 @@ +Template.actionSheet.created = function () { + // this.actionText = new ReactiveVar(); +}; + +Template.actionSheet.events({ + 'click [data-action=showActionSheet]': function (event, template) { + IonActionSheet.show({ + titleText: 'ActionSheet Example', + buttons: [ + { text: 'Share ' }, + { text: 'Move ' }, + ], + destructiveText: 'Delete', + cancelText: 'Cancel', + cancel: function() { + alert('CANCELLED'); + }, + buttonClicked: function(index) { + alert('BUTTON CLICKED', index); + return true; + }, + destructiveButtonClicked: function() { + alert('DESTRUCT'); + return true; + } + }); + } +});