Skip to content

Commit

Permalink
Merge pull request #63 from legalthings/fix-fn-on-undefined
Browse files Browse the repository at this point in the history
Uncaught TypeError: Cannot read property 'fn' of undefined
  • Loading branch information
jasny authored May 19, 2017
2 parents d4dcf28 + f8c4981 commit 0b1235a
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions js/to-material.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,44 @@
*
* @param $docWizard
*/
$.fn.toMaterial = function() {
var $docWizard = $(this);

// Add class to the material design to prevent another styles for it.
$docWizard.addClass('material');
(function($) {
$.fn.toMaterial = function() {
var $docWizard = $(this);

// Add class to the material design to prevent another styles for it.
$docWizard.addClass('material');

// Added prev-next button to the each step
var $wizardSteps = $docWizard.find('.wizard-step');
// Added prev-next button to the each step
var $wizardSteps = $docWizard.find('.wizard-step');

$wizardSteps.each(function(index, value) {
var $wizardForm = $('<div>').appendTo(this);
$wizardForm.addClass('wizzard-form');
$wizardForm.append($(this).find('form'));
$wizardForm.append($(this).find('.wizards-actions'));
});
$wizardSteps.each(function(index, value) {
var $wizardForm = $('<div>').appendTo(this);
$wizardForm.addClass('wizzard-form');
$wizardForm.append($(this).find('form'));
$wizardForm.append($(this).find('.wizards-actions'));
});

// Change checkboxes to the bootstrap material
$docWizard.find('.form-group .option').each(function() {
var $div = $(this);
var type = 'radio';
$div.addClass($div.find('input').attr('type'));
$div.find('input').prependTo($div.find('label'));
});
// Change checkboxes to the bootstrap material
$docWizard.find('.form-group .option').each(function() {
var $div = $(this);
var type = 'radio';
$div.addClass($div.find('input').attr('type'));
$div.find('input').prependTo($div.find('label'));
});

// Change likert-view on bootstrap material
$docWizard.find('.likert-answer').each(function(){
var $div = $('<div>').appendTo(this).addClass('radio');
var $label = $('<label>').appendTo($div);
$(this).find('input').appendTo($label);
});
// Change likert-view on bootstrap material
$docWizard.find('.likert-answer').each(function(){
var $div = $('<div>').appendTo(this).addClass('radio');
var $label = $('<label>').appendTo($div);
$(this).find('input').appendTo($label);
});

// Do all labels floating for nice view
$docWizard.find('.form-group').addClass('label-floating');
$docWizard.find('.form-group > label').addClass('control-label');
// Do all labels floating for nice view
$docWizard.find('.form-group').addClass('label-floating');
$docWizard.find('.form-group > label').addClass('control-label');

if ($.material) {
$.material.init();
}
};
if ($.material) {
$.material.init();
}
};
})(jQuery);

0 comments on commit 0b1235a

Please sign in to comment.