webksde

How to detect multiline text with jQuery

Currently there is no way to do this job just with css. I saw various Javascript solutions to do this, most of them are way to complicated (for my use case).

In my case i just need it to detect multiline field labels. So … as i have a fix font size here, i just look out for the elements height via jquery and add a multiline class if its higher then on line of text.

Idea to modify this: Get the height of a one-liner label dynamically (compare the determined height values and use the flattest, also check for empty labels …).

        /* Check if field labels are heigher then one line */
        $(".entityform label").each(function( index ) {
          label = $(this);
          labelHeight = label.height();
          if(labelHeight > 20){
            label.addClass('multiline-label');
          }
        });

    Fixed positioned element is aligned relative to the parent

    If you have an fixed element which is curiously positioned relative to it´s parent (what is definitely against the specification „An element with a fixed position is positioned relative to the browser window, and will not move even if the window is scrolled – http://www.w3schools.com/css/css_positioning.asp“), you probably have something done with the transform-property on any of the parent elements.

    This will cause this totally absurd behavoir (in every major browser, so maybe the transform specification sucks, or the w3c has some.. reason to do this kind of sh** … whatever).

    Here is an example of the „bug“: http://codepen.io/anon/pen/gpPVZV

    Thanks a lot to Mr. Blairhippo you saved my day.

      Shopware (4) Kategoriebild in der Kategoriebeschreibung ausgeben

      Warum auch immer das nicht von Shopware aus schon implementiert ist, hier eine Variante welche die Bilder (hochzuladen im Backend > Kategorien > KategorieX) in der Kategoriebeschreibung ausgibt.

      Die betroffene Templatedatei beinfdet sich im ordner frontend/listing/text.tpl. Zusätzlich sollte im Media Manager ein eigener Ordner „Kategoriebilder“ o.Ä. angelegt werden. In den Einstellungen des Ordners (rechtsklick auf den Ordner), muss nun noch die Thumbnail Generierung eingerichtet werden.

      Diese Lösung ist alles andere als perfekt, aber vllt. rettet es ja dem ein oder anderen den Tag 🙂
      Anzupassen ist die Thumbnail Size, der Pfad sollte identisch sein.

                    {assign var="category_thumbnail_size" value="120x120"}
                    {assign var="category_thumbnail" value="media/image/thumbnail/{$sCategoryContent.media.name}_{$category_thumbnail_size}.{$sCategoryContent.media.extension}"}
                    
                    {if !file_exists($category_thumbnail)}
                      {* FALLBACK *}
                      {assign var="category_thumbnail" value="{$sCategoryContent.media.path}"}
                    {/if}
                    {if $category_thumbnail}
                      {$sCategoryContent.cmsheadline}
                    {/if}
      

        CSS Keyframe Animation fade out and hide without display:none

        The Display property is not working well with CSS animations, if you read this, you already know. So we have to find a way around.

        In my case, i have a layer above the entire page which is overlaying the page content. As you already tried out, visibility won´t work also, as it´s the same as opacity:0;

        Solutions:

        1. You can move the entire layer out of the viewport eg. position:absolute; left:-9000px;
        2. You can try out using a negative z-index to get the layer behind the page-content (makes only sense for layers which are absolute / fixed positioned over the page, not in normal element flow).
        3. Make overflow:hidden; and height:0; – take a look:
        @keyframes fadeOutAndHide {
            0% {
              opacity:1.0;
            }
            99%{
              opacity:0;
              height:100%;
            }
            100% {
              height:0;
            }
        }
        .page-welcome-layer.hidden{
          animation:fadeOutAndHide ease-in 1.5s;
          animation-fill-mode:forwards;
          animation-iteration-count: 1;
          overflow:hidden;
        }
        

          Stop OWL Carousel 1.x if theres only one slide

                  // Stop OWL Carousel if theres only one slide
                  $owlContainers = jQuery(".owl-carousel");
                  $owlContainers.each(function () {
                    $owlContainer = $(this);
                    $owlSlides = $owlContainer.find('div.owl-item');
                    alert($owlSlides.length);
                    // More than one slide - initialize the carousel
                    if ($owlSlides.length <= 1) {
                      $owlContainer.data('owlCarousel').stop();
                    }
                  });
          

            Remove Drupals .menu-position-link menu items (Menu Position module)

            Menu Position is a great Drupal Module to get the .active-trail class in the menu, without adding eg. all news article nodes to the it.

            The only problem is a „placeholder“ link created instead, class: „.menu-position-link“. It seems this is technically necessary.

            Here is a little jQuery function to remove the element itself, the container menu (if its the only item) and fix the causing classes. You may have to alter it a bit.

            Remove the console.logs before using it on productive environment!

            $('.menu', context).children('li.active-trail').each(function() {
              var menuChildCount = $(this).children('.menu').children('li').length;
              var $menuPosLinkParent = $(this).find('.menu-position-link').parent();
              if ($menuPosLinkParent.length) {
                console.log('Found one - childcount:' + menuChildCount);
                console.log($menuPosLinkParent);
                if (($menuPosLinkParent).hasClass('last')) {
                  console.log('Its the last item.');
                  // If its the last link move class .last to the menu item before 
                  $menuPosLinkParent.prev('li').addClass('last');
                }
                if (menuChildCount === 1) {
                  console.log('Its the only item.');
                  // If menu position link is the only menu-item, remove parent trails .expanded 
                  $menuPosLinkParent.parents('li.active-trail.expanded').removeClass('expanded');
                  $menuPosLinkParent.parent('.menu').remove();
                  console.log('Removed it.');
                } else {
                  $menuPosLinkParent.remove();
                  console.log('Removed it.');
                }
              }
            });

              Webfont rendered a lot to thick in Google Chrome

              Webfonts currently will be rendered differently in Chrome and Firefox, so especially under Windows Chrome has a really bad font anti aliasing. But sometimes thats not the point.
               
              First make sure you have set the font-weight correctly. If this does not help, you might have the font installed locally? No? I´m sure, you have! You needed it for your screendesign 😉 
               
              Delete the font locally and reload your website (maybe you have to restart chrome), the font should be rendered fine now. Take care deleting the whole font.

                Pixelperc.com offline -> Ersatz

                Da Pixelperc.com plötzlich offline ist und ich das Tool einfach grandios hilfreich finde, haben wir die aktuelle Version von Github mal bei uns bereit gestellt.

                Update: Nun unter neuer Adresse wieder erreichbar: http://pauladamdavis.github.io/PixelPerc/

                  Tipp: Velositey für Photoshop CS6 + CC

                  Photoshop wurde grundsätzlich nicht mehr Webdesign konzipiert, entsprechend fehlen einige Komfortfunktionen für Webdesigner.

                  Das PlugIn Velositey hilft Photshop etwas auf die Sprünge und bietet neben der Generierung von 1170 Pixel Grids und weiterer Guide-Vorlagen eine ordentliche Anzahl von Basislayouts welche einem schon ordentlich Arbeit abnehmen können.

                  Toller kleiner Helfer und das kostenlos!