Front end of the Slack clone application.

picker.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { EventEmitter, Output } from '@angular/core';
  2. import { isPresent } from '../../util/util';
  3. import { PickerCmp } from './picker-component';
  4. import { PickerSlideIn, PickerSlideOut } from './picker-transitions';
  5. import { ViewController } from '../../navigation/view-controller';
  6. /**
  7. * @hidden
  8. */
  9. export class Picker extends ViewController {
  10. constructor(app, opts = {}, config) {
  11. if (!opts) {
  12. opts = {};
  13. }
  14. opts.columns = opts.columns || [];
  15. opts.buttons = opts.buttons || [];
  16. opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? Boolean(opts.enableBackdropDismiss) : true;
  17. super(PickerCmp, opts, null);
  18. this._app = app;
  19. this.isOverlay = true;
  20. this.ionChange = new EventEmitter();
  21. config.setTransition('picker-slide-in', PickerSlideIn);
  22. config.setTransition('picker-slide-out', PickerSlideOut);
  23. }
  24. /**
  25. * @hidden
  26. */
  27. getTransitionName(direction) {
  28. let key = (direction === 'back' ? 'pickerLeave' : 'pickerEnter');
  29. return this._nav && this._nav.config.get(key);
  30. }
  31. /**
  32. * @param {any} button Picker toolbar button
  33. */
  34. addButton(button) {
  35. this.data.buttons.push(button);
  36. }
  37. /**
  38. * @param {PickerColumn} column Picker toolbar button
  39. */
  40. addColumn(column) {
  41. this.data.columns.push(column);
  42. }
  43. getColumns() {
  44. return this.data.columns;
  45. }
  46. getColumn(name) {
  47. return this.getColumns().find(column => column.name === name);
  48. }
  49. refresh() {
  50. (void 0) /* assert */;
  51. (void 0) /* assert */;
  52. this._cmp && this._cmp.instance.refresh && this._cmp.instance.refresh();
  53. }
  54. /**
  55. * @param {string} cssClass CSS class name to add to the picker's outer wrapper.
  56. */
  57. setCssClass(cssClass) {
  58. this.data.cssClass = cssClass;
  59. }
  60. /**
  61. * Present the picker instance.
  62. *
  63. * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
  64. * @returns {Promise} Returns a promise which is resolved when the transition has completed.
  65. */
  66. present(navOptions = {}) {
  67. return this._app.present(this, navOptions);
  68. }
  69. }
  70. Picker.propDecorators = {
  71. 'ionChange': [{ type: Output },],
  72. };
  73. //# sourceMappingURL=picker.js.map