Onatolich Interface Solutions

591
.
AlkatraZ, Я понял. Завтра сделаю и скину в личку.
.
AlkatraZ (18.03.2013 / 18:35)
Вот кстати еще ссылка на подобные исследования: http://xozblog.ru/2012/10/chec ... css3/
Неее. Там дополнительная разметка используется, а в моем примере такого нет.
.
Полоса прогреса.

jQuery плагин:
(function($){
  jQuery.fn.progressline = function(options){

    var e = this;

    var options = $.extend({
        height:    '12px',
        maximum:   100,
        value:     0,
        showValue: true,
        width:     '300px'
    }, {
        height:    e.data('height'),
        maximum:   e.data('maximum'),
        value:     e.data('value'),
        showValue: e.data('showValue'),
        width:     e.data('width')
    }, options);

/*-------------------------------------------------------------------*/

    var handler = function(){
        if(options.value > options.maximum) options.value = options.maximum;
        e.data('height', options.height); e.data('maximum', options.maximum); e.data('value', options.value); e.data('showValue', options.showValue); e.data('width', options.width);

        if(!e.hasClass('ois-progressline'))
        {
            e.addClass('ois-progressline').css('width', options.width);
            $('<section></section>').addClass('ois-progressline-line').css({
                height: options.height,
                width: Math.ceil((e.width() + 2) * options.value / options.maximum) + 'px'
            }).appendTo(e);

            if(options.showValue) $('<section></section>').addClass('ois-progressline-value').text(options.value).appendTo(e);
        }

        e.css('width', options.width).find('section.ois-progressline-line').css({
            height: options.height,
            width: Math.ceil((e.width() + 2) * options.value / options.maximum) + 'px'
        });
        e.find('section.ois-progressline-value').text(options.value + '%');
    }

/*-------------------------------------------------------------------*/

    return this.each(handler);
  }
})(jQuery);


CSS:
/* Главный блок */
.ois-progressline{
  background: #d0d3e8;
  margin: 5px 4px;
  position: relative;
  text-align: left;
}

/* Заполненное */
.ois-progressline-line{
  background: #6890ba;
  display: block;
  height: 8px;
  margin: -1px;
}

/* Значение */
.ois-progressline-value{
  color: #6890ba;
  cursor: default;
  font-size: 7pt;
  position: absolute;
  right: 0; bottom: 100%;
}


Вызов:
<div id="pline"></div>

<script>
    $('#pline').progressline({
        height: '12px',
        maximum: 100,
        value: 30,
        showValue: true,
        width: '200px'
    });

    $('#pline').live('click', function(){
        $(this).progressline({ value: $(this).data('value') + 10 });
    });
</script>


Этот код создаст линию прогресса с начальным значением 30% и при каждом клике на линию увеличивает его на 10%
Прикрепленные файлы:
Всего: 23