Skip to content

Commit

Permalink
Improve test for empty form
Browse files Browse the repository at this point in the history
  • Loading branch information
billtomczak committed Jul 12, 2022
1 parent 425480d commit b5f6c39
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/media/js/jquery.osdownloads.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

$btnContinue.prop('href', $this.prop('href'));

if ($btnContinue.length) {
if ($btnContinue.length && $form[0].elements.length) {
showPopup('#' + popupElementId);

$popup.on(
Expand Down
2 changes: 1 addition & 1 deletion src/media/js/jquery.osdownloads.bundle.min.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;jQuery(function($){$.fn.osdownloads=function osdownloads(options){if(this.length){return this.each(function(){if($(this).data('osdownloads-loaded')===1){return;}
let $this=$(this),prefix=$this.data('prefix'),animation=$this.data('animation'),popupElementId=prefix+'_popup',$popup=$('#'+popupElementId),$btnContinue=$popup.find('.osdownloads-continue-button'),$form=$popup.find('form');if($popup.length!==1&&$form.length!==1){return;}
$popup.appendTo($('body'));let $validator=$form.validate();let showPopup=function(selector){$(selector).reveal({animation:animation,animationspeed:200,closeonbackgroundclick:true,dismissmodalclass:'close-reveal-modal',});};let download=function(){$form.prop('target','osdownloads-tmp-iframe-'+$form.prop('id'));$container=$('<div>').prop('id',prefix+'PopupIframe').addClass('reveal-modal').addClass('osdownloads-modal');$iframe=$('<iframe>').prop('name','osdownloads-tmp-iframe-'+$form.prop('id'));$close=$('<a class="close-reveal-modal">&#215;</a>');$iframe.appendTo($container);$close.appendTo($container);$container.appendTo($('body'));$form.submit();$container.on('reveal:close',function(){setTimeout(function(){$container.remove();},500);});$popup.trigger('reveal:close');setTimeout(function(){showPopup('#'+prefix+'PopupIframe');},500);};$this.on('click',function(event){event.preventDefault();event.stopPropagation();$btnContinue.prop('href',$this.prop('href'));if($btnContinue.length){showPopup('#'+popupElementId);$popup.on('reveal:close',function(){setTimeout(function(){$form[0].reset();$validator.resetForm();},500);});$btnContinue.off();$btnContinue.on('click',function(event){event.preventDefault();if($form.valid()){download();}});}else{download();}});$this.data('osdownloads-loaded',1);});}};});(function($){$('a[data-reveal-id]').on('click',function(event){event.preventDefault();var modalLocation=$(this).attr('data-reveal-id');$('#'+modalLocation).reveal($(this).data());});$.fn.reveal=function(options){var defaults={animation:'fadeAndPop',animationSpeed:300,closeOnBackgroundClick:true,dismissModalClass:'close-reveal-modal'};var options=$.extend({},defaults,options);return this.each(function(){var modal=$(this),topMeasure=parseInt(modal.css('top')),topOffset=modal.height()+topMeasure,locked=false,modalBg=$('.reveal-modal-bg');if(modalBg.length==0){modalBg=$('<div class="reveal-modal-bg" />').insertAfter(modal);modalBg.fadeTo('fast',0.8);}
$popup.appendTo($('body'));let $validator=$form.validate();let showPopup=function(selector){$(selector).reveal({animation:animation,animationspeed:200,closeonbackgroundclick:true,dismissmodalclass:'close-reveal-modal',});};let download=function(){$form.prop('target','osdownloads-tmp-iframe-'+$form.prop('id'));$container=$('<div>').prop('id',prefix+'PopupIframe').addClass('reveal-modal').addClass('osdownloads-modal');$iframe=$('<iframe>').prop('name','osdownloads-tmp-iframe-'+$form.prop('id'));$close=$('<a class="close-reveal-modal">&#215;</a>');$iframe.appendTo($container);$close.appendTo($container);$container.appendTo($('body'));$form.submit();$container.on('reveal:close',function(){setTimeout(function(){$container.remove();},500);});$popup.trigger('reveal:close');setTimeout(function(){showPopup('#'+prefix+'PopupIframe');},500);};$this.on('click',function(event){event.preventDefault();event.stopPropagation();$btnContinue.prop('href',$this.prop('href'));if($btnContinue.length&&$form[0].elements.length){showPopup('#'+popupElementId);$popup.on('reveal:close',function(){setTimeout(function(){$form[0].reset();$validator.resetForm();},500);});$btnContinue.off();$btnContinue.on('click',function(event){event.preventDefault();if($form.valid()){download();}});}else{download();}});$this.data('osdownloads-loaded',1);});}};});(function($){$('a[data-reveal-id]').on('click',function(event){event.preventDefault();var modalLocation=$(this).attr('data-reveal-id');$('#'+modalLocation).reveal($(this).data());});$.fn.reveal=function(options){var defaults={animation:'fadeAndPop',animationSpeed:300,closeOnBackgroundClick:true,dismissModalClass:'close-reveal-modal'};var options=$.extend({},defaults,options);return this.each(function(){var modal=$(this),topMeasure=parseInt(modal.css('top')),topOffset=modal.height()+topMeasure,locked=false,modalBg=$('.reveal-modal-bg');if(modalBg.length==0){modalBg=$('<div class="reveal-modal-bg" />').insertAfter(modal);modalBg.fadeTo('fast',0.8);}
function openAnimation(){modalBg.unbind('click.modalEvent');$('.'+options.dismissModalClass).unbind('click.modalEvent');if(!locked){lockModal();if(options.animation=="fadeAndPop"){modal.css({'top':$(document).scrollTop()-topOffset,'opacity':0,'visibility':'visible'});modalBg.fadeIn(options.animationSpeed / 2);modal.delay(options.animationSpeed / 2).animate({"top":$(document).scrollTop()+topMeasure+'px',"opacity":1},options.animationSpeed,unlockModal);}
if(options.animation=="fade"){modal.css({'opacity':0,'visibility':'visible','top':$(document).scrollTop()+topMeasure});modalBg.fadeIn(options.animationSpeed / 2);modal.delay(options.animationSpeed / 2).animate({"opacity":1},options.animationSpeed,unlockModal);}
if(options.animation=="none"){modal.css({'visibility':'visible','top':$(document).scrollTop()+topMeasure});modalBg.css({"display":"block"});unlockModal();}}
Expand Down
2 changes: 1 addition & 1 deletion src/media/js/jquery.osdownloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

$btnContinue.prop('href', $this.prop('href'));

if ($btnContinue.length) {
if ($btnContinue.length && $form[0].elements.length) {
showPopup('#' + popupElementId);

$popup.on(
Expand Down

0 comments on commit b5f6c39

Please sign in to comment.