cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              import {Component, AfterViewChecked, ViewChild, OnDestroy} from '@angular/core';
import {NavController, NavParams, Content} from 'ionic-angular';

import {PartnerService} from "../../services/partner-service";
import {ChooseLocationManuallyComponent} from "./choose-location-manually/choose-location-manually-component";
import {AlertController} from 'ionic-angular';
import {PartnerDetailComponent} from "./partner-detail-component/partner-detail-component";
import {LocationService} from "../../services/location-service";
import {style, state, trigger, transition, animate} from "@angular/animations";

@Component({
  selector: 'partner-page-component',
  templateUrl: 'partner-page-component.html',
  animations: [trigger('show', [state('false', style({
    height: '0vh'
  })),
  state('true', style({
    height: '84vh'
  })),
    transition('false <=> true', animate('500ms'))
  ])]
})
export class PartnerPageComponent implements AfterViewChecked, OnDestroy {
  @ViewChild(Content) content: Content;
  title = "Partner";
  mode = "Observable";
  getPartnersSubscription: any;
  getLocationNameSubscription: any;
  getLocationSubscription: any;

  location = {latitude: "0", longitude: "0"};

  showCustomBackButton = false;
  showDropdown = [false, false, false];
  showDropdownForAnimation = ["false", "false"];


  waitingForResults: boolean = true;
  mapWaitingForResults;
  waitingForGPSSignal = false;

  errorMessage: string;

  showMap = false;
  showMapIcon = false;

  displayedPartners = [];

  offlinePartners = [];
  onlinePartners = [];
  allPartners = [];
  partnersWithCampaign = [];
  resetPartnersArray: boolean = true;
  moreDataCanBeLoaded = true;
  bucket: number = 0;
  searchTerm = "";

  showOfflinePartners = false;
  showOnlinePartners = false;
  showOnlyPartnersWithCampaign = false;
  pageType: string;
  onlinePartnerPageComponent = false;
  offlinePartnerPageComponent = false;
  searchPageComponent = false;

  getLocationFromGPSEnabled = false;
  cityName;

  searchInterfaceOpen: boolean = false;

  public ngAfterViewChecked() {
    this.setFocus();
  }

  ngOnDestroy() {
    if (this.getLocationSubscription) {
      this.getLocationSubscription.unsubscribe();
    }
    if (this.getPartnersSubscription) {
      this.getPartnersSubscription.unsubscribe();
    }
  }

  constructor(public navCtrl: NavController,
              public navParams: NavParams,
              private partnerService: PartnerService,
              public alertCtrl: AlertController,
              public locationService: LocationService) {

    let pageType = navParams.get("type");
    this[pageType] = true;
    this.pageType = pageType;
    this.searchTerm = navParams.get("searchTerm") || "";
    this.getLocationFromGPSEnabled = (localStorage.getItem("getLocationFromGPSEnabled") === "true");
    this.cityName = localStorage.getItem("cityName") || "Berlin";
    this.setParameters();
  }

  setParameters() {
    //for legal reasons, some methods are omitted
  }

  getManuallySetLocationData() {
    if (localStorage.getItem("locationAvailable") === "true") {
      this.location.latitude = localStorage.getItem("latitude");
      this.location.longitude = localStorage.getItem("longitude");
    }
    else {
      this.location.latitude = "52.5219";
      this.location.longitude = "13.4132";
    }
  }

  showPromptGPSDisabled() {
        //for legal reasons, some methods are omitted
  }

  getPartnersWithSearchTerm(searchTerm) {
    this.searchInterfaceOpen = false;
    this.showCustomBackButton = true;
    this.searchTerm = searchTerm + " ";
    this.getPartners();
    this.title = searchTerm;
  }

  getPartners() {
    //for legal reasons, some methods are omitted
  }

  getDifferentCategories(returnedObject) {
        //for legal reasons, some methods are omitted
  }

  filterButtonPushed() {
    if (this.showOfflinePartners) {
      this.waitingForResults = true;
      this.mapWaitingForResults = true;
      this.checkIfGPSEnabled();
    }
    else {
      this.waitingForResults = true;
      this.getDisplay();
    }
    this.showDropdown = [false, false, false];
    this.showDropdownForAnimation = ["false", "false"];
  }

  getDisplay() {
        //for legal reasons, some methods are omitted
  }


  chooseLocationManually() {
    event.stopPropagation();
    this.navCtrl.push(ChooseLocationManuallyComponent, {
      type: this.pageType,
      showOfflinePartners: this.showOfflinePartners,
      showOnlinePartners: this.showOnlinePartners,
      showOnlyPartnersWithCampaign: this.showOnlyPartnersWithCampaign,
    });
    this.showDropdown = [false, false, false];
    this.showDropdownForAnimation = ["false", "false"];
  }


  showPartner(partner = 0) {
       //for legal reasons, some methods are omitted
  }


  filterCampaignPartners(displayedPartners) {
        //for legal reasons, some methods are omitted
  }

  askForValidCategories() {
    let prompt = this.alertCtrl.create({
      title: 'Bitte wählen Sie entweder "Vor-Ort-Partner" oder "Online Partner" aus',
      buttons: [
        {
          text: 'OK',
          handler: data => {
          }
        }
      ]
    });
    prompt.present();
    this.showDropdown = [true, false, true];
    this.showDropdownForAnimation = ["true", "false"];
  }

  toggleMapAndList() {
    this.showMap = !this.showMap;
    this.mapWaitingForResults = true;
    this.showDropdown = [false, false, false];
    this.showDropdownForAnimation = ["false", "false"];
  }

  toggleGetLocationFromGPSEnabled() {
    let newValueGetLocationFromGPSEnabled = !this.getLocationFromGPSEnabled;
    if (newValueGetLocationFromGPSEnabled) {
      this.waitingForGPSSignal = true;
      this.getLocationSubscription = this.locationService.getLocation().subscribe(
        (object) => {
          if (object.locationFound == true) {
            this.waitingForGPSSignal = false;
            this.location.latitude = object.lat;
            this.location.longitude = object.lon;
            this.getLocationFromGPSEnabled = true;
            localStorage.setItem("getLocationFromGPSEnabled", "true");
            this.getLocationNameSubscription = this.locationService.getLocationName(this.location.latitude, this.location.longitude).subscribe((cityName) => {
              this.cityName = cityName
            })
          }
          else {
            this.showPromptGPSDisabled();
            this.waitingForGPSSignal = false;
          }
        }
      )
    }
    else {
      localStorage.setItem("getLocationFromGPSEnabled", "false");
      this.getLocationFromGPSEnabled = false;
      this.getManuallySetLocationData();
    }
  }

//pure DOM methods

  private setFocus() {
    let searchInputField = document.getElementById('mySearchInputField');
    if (searchInputField) {
      searchInputField.focus();
    }
  }

  hideDropdown() {
    this.showDropdown = [false, false, false];
    this.showDropdownForAnimation = ["false", "false"];
  }


  toggleVisibilityDropdowns(position) {
        //for legal reasons, some methods are omitted
  }

  closeSearchInterface() {
        //for legal reasons, some methods are omitted
  }

  doInfinite(infiniteScroll) {
    this.bucket += 50;
    this.resetPartnersArray = false;
    this.getPartners();
    infiniteScroll.complete();
  }

  customBackButtonClicked() {
    this.navCtrl.pop();
  }

}

            
          
!
999px
Loading ..................

Console