SORU
31 Mayıs 2009, Pazar


Metin alanları için bir WordPress kullanmak otomatik büyüme bir eklenti var mı?

Bir autogrowing için çeşitli eklentileri buldumbuttonama giriş metin alanları. Kimse yok mu, varsa biliyor mu?

CEVAP
31 Mayıs 2009, Pazar


İşte sonra sen ne işe yarayacak bir eklenti:

EDİT: Mathias göre eklenti' yorum. düzelttim :)

Bir demo buraya bakın:http://jsfiddle.net/rRHzY

Eklenti:

(function($){

    $.fn.autoGrowInput = function(o) {

        o = $.extend({
            maxWidth: 1000,
            minWidth: 0,
            comfortZone: 70
        }, o);

        this.filter('input:text').each(function(){

            var minWidth = o.minWidth || $(this).width(),
                val = '',
                input = $(this),
                testSubject = $('<tester/>').css({
                    position: 'absolute',
                    top: -9999,
                    left: -9999,
                    width: 'auto',
                    fontSize: input.css('fontSize'),
                    fontFamily: input.css('fontFamily'),
                    fontWeight: input.css('fontWeight'),
                    letterSpacing: input.css('letterSpacing'),
                    whiteSpace: 'nowrap'
                }),
                check = function() {

                    if (val === (val = input.val())) {return;}

                    // Enter new content into testSubject
                    var escaped = val.replace(/&/g, '&').replace(/\s/g,' ').replace(/</g, '<').replace(/>/g, '>');
                    testSubject.html(escaped);

                    // Calculate new width   whether to change
                    var testerWidth = testSubject.width(),
                        newWidth = (testerWidth   o.comfortZone) >= minWidth ? testerWidth   o.comfortZone : minWidth,
                        currentWidth = input.width(),
                        isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth)
                                             || (newWidth > minWidth && newWidth < o.maxWidth);

                    // Animate width
                    if (isValidWidthChange) {
                        input.width(newWidth);
                    }

                };

            testSubject.insertAfter(input);

            $(this).bind('keyup keydown blur update', check);

        });

        return this;

    };

})(jQuery);

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Shon Gonzales

    Shon Gonzale

    5 EKİM 2014
  • TopDJMag TV

    TopDJMag TV

    29 Temmuz 2010
  • TotalxLuna

    TotalxLuna

    27 Kasım 2011