'use strict';
(function ($) {
  $(document).ready(function () {
    // Setup media query for enabling dynamic layouts only on
    // larger screen sizes
    var mq = window.matchMedia("(min-width: 480px)");
    if ($(".userrole-anonymous")[0]){
      $('input[type="password"]').showPassword('focus', {
      });
      $('.app-signin-input').jvFloat();
      var $mcNote = $('#app-signin-suggestion');
      Mailcheck.defaultDomains.push('mitr.kreativkombinat.de')
      $('#ac-name').on('blur', function (event) {
        console.log("event ", event);
        console.log("this ", $(this));
        $(this).mailcheck({
          // domains: domains,                       // optional
          // topLevelDomains: topLevelDomains,       // optional
          suggested: function (element, suggestion) {
                // callback code
                console.log("suggestion ", suggestion.full);
                $mcNote.removeClass('hidden').addClass('fadeInDown');
                $mcNote.html("Meinten Sie <i>" + suggestion.full + "</i>?");
                $mcNote.on('click', function (evt) {
                  evt.preventDefault();
                  $('#ac-name').val(suggestion.full);
                  $mcNote.removeClass('fadeInDown').addClass('fadeOutUp').delay(2000).addClass('hidden');
                });
              },
          empty: function (element) {
                // callback code
                $mcNote.html('').addClass('hidden');
              }
        });
      });
      // Enable gallery and masonry scripts based on screen size
      if (mq.matches) {
        var bannerflkty = new Flickity('.app-js-carousel', {
          autoPlay: true,
          contain: true,
          wrapAround: true,
          imagesLoaded: true,
          cellSelector: '.app-banner-item',
          cellAlign: 'left'
        });
        //var flkty = new Flickity('.main-gallery', {
        //  autoPlay: true,
        //  contain: true,
        //  wrapAround: true,
        //  imagesLoaded: true,
        //  cellSelector: '.app-gallery-cell',
        //  cellAlign: 'left'
        //});
        //var $isoContainer = $('#js-isotope-container');
        //$isoContainer.addClass('js-isotope-intialized');
        //$isoContainer.isotope({
        //  itemSelector: '.js-isotope-item',
        //  layoutMode: 'fitRows',
        //  animationOptions: {
        //    duration: 750,
        //    easing: 'linear',
        //    queue: false
        //  },
        //  resizable: false,
        //  animationEngine: 'best-available'
        //});
        //// filter items on button click
        //var $selectionLinks = $('[data-appui="app-list-filter"]'),
        //    $current = '';
        //$('#app-list-filters').on('click', '[data-appui="app-list-filter"]', function () {
        //  $current = $(this);
        //  $selectionLinks.not($current).removeClass('active-filter');
        //  $(this).addClass('active-filter');
        //  var $filterValue = $(this).attr('data-filter');
        //  $isoContainer.isotope({ filter: $filterValue });
        //});
      }
    };
  }
  );
}(jQuery));
