Sha256: 681dee9771bf5e77669f3b06835edd2ceb72107a1204f98d4b6282ddef144e64
Contents?: true
Size: 1.93 KB
Versions: 54
Compression:
Stored size: 1.93 KB
Contents
/** * Step form wrapper. * * @author Htmlstream * @version 1.0 * */ ;(function ($) { 'use strict'; $.HSCore.components.HSStepForm = { /** * * * @var Object _baseConfig */ _baseConfig: {}, /** * * * @var jQuery pageCollection */ pageCollection: $(), /** * Initialization of Step form wrapper. * * @param String selector (optional) * @param Object config (optional) * * @return jQuery pageCollection - collection of initialized items. */ init: function (selector, config) { this.collection = selector && $(selector).length ? $(selector) : $(); if (!$(selector).length) return; this.config = config && $.isPlainObject(config) ? $.extend({}, this._baseConfig, config) : this._baseConfig; this.config.itemSelector = selector; this.initStepForm(); return this.pageCollection; }, initStepForm: function () { //Variables var $self = this, collection = $self.pageCollection; //Actions this.collection.each(function (i, el) { //Variables var $this = $(el); var setProgress = function (currstep) { var percent; percent = parseFloat(100 / widget.length) * currstep; percent = percent.toFixed(); $this.val(percent); }, current = 1, widget = $('.js-step'), btnNext = $('.js-step-next'); // Init buttons and UI widget.not(':eq(0)').hide(); setProgress(current); // Next button click action btnNext.click(function (e) { e.preventDefault(); if (current < widget.length) { widget.show(); widget.not(':eq(' + (current++) + ')').hide(); setProgress(current); } }); //Actions collection = collection.add($this); }); } }; })(jQuery);
Version data entries
54 entries across 54 versions & 1 rubygems