!function ($) { var old = $.fn.morphingButton $.fn.morphingButton = function (option) { var $this = $(this); if(option == undefined){ $(this).wrap('
'); $(this).addClass('btn-toggle'); $container = $(this).parent('.btn-morphing'); $container.append(''); if($(this).hasClass('btn-lg')){ $container.append(''); $container.addClass('morphing-lg'); } else { $container.append(''); } if($(this).hasClass('btn-round')){ $container.find('path').css('stroke-width','1px'); } $(this).click(function(){ button = this; $rotation_color = $(this).data('rotation-color'); $parent = $(this).parent('.btn-morphing'); $path = $parent.find('path'); $svg = $parent.find('svg'); $(this).addClass('resize'); $(this).html(''); setTimeout(function(){ $(button).css('border-color','transparent'); $svg.attr('class','rotation-animate'); $path.attr('class','circle circle-animation'); if($rotation_color != undefined && $rotation_color != ''){ $path.attr('class','circle circle-animation circle-' + $rotation_color); } else { $path.attr('class','circle circle-animation circle-gray'); } $parent.find('span').css('display','block'); $parent.find('svg').css('display','block'); $(button).css('pointer-events','none'); }, 420); }); } else if(option){ if(option.action == 'setState'){ state = option.state; icon = option.icon; $item = $(this); $parent = $item.parent('.btn-morphing'); $parent.addClass('morphing-' + state); $path = $parent.find('path'); $svg = $parent.find('svg'); $parent.find('.fa').addClass(icon).addClass('visible'); $path.css('stroke-dashoffset',0).attr('class','circle');; setTimeout(function(){ $svg.removeAttr('class'); }, 500); } } } /* CHECKBOX NO CONFLICT * ================== */ $.fn.morphingButton.noConflict = function () { $.fn.morphingButton = old; return this; } }(window.jQuery);