123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @hidden
  3. */
  4. var DisplayWhen = (function () {
  5. function DisplayWhen(conditions, _plt, zone) {
  6. this._plt = _plt;
  7. this.zone = zone;
  8. this.isMatch = false;
  9. if (!conditions)
  10. return;
  11. this.conditions = conditions.replace(/\s/g, '').split(',');
  12. // check if its one of the matching platforms first
  13. // a platform does not change during the life of an app
  14. for (var i = 0; i < this.conditions.length; i++) {
  15. if (this.conditions[i] && _plt.is(this.conditions[i])) {
  16. this.isMatch = true;
  17. return;
  18. }
  19. }
  20. if (this.orientation()) {
  21. // add window resize listener
  22. this.resizeObs = _plt.resize.subscribe(this.orientation.bind(this));
  23. }
  24. }
  25. DisplayWhen.prototype.orientation = function () {
  26. for (var i = 0; i < this.conditions.length; i++) {
  27. if (this.conditions[i] === 'portrait') {
  28. this.isMatch = this._plt.isPortrait();
  29. return true;
  30. }
  31. if (this.conditions[i] === 'landscape') {
  32. this.isMatch = this._plt.isLandscape();
  33. return true;
  34. }
  35. }
  36. return false;
  37. };
  38. DisplayWhen.prototype.ngOnDestroy = function () {
  39. this.resizeObs && this.resizeObs.unsubscribe();
  40. this.resizeObs = null;
  41. };
  42. return DisplayWhen;
  43. }());
  44. export { DisplayWhen };
  45. //# sourceMappingURL=display-when.js.map