cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <section>
  <div>
    <H1>Save Button with Loading And Confirmation</H1>
    <button class="btn prog-btn">
      <span class="content">Save & Apply</span>
      <span class="progress"></span>
      </span>
    </button> <!--//button-->
    <br />
    <a href="#">Reset Button</a>
    <label for="reset">Tigger error?</label>
    <input type="checkbox" id='reset' />
  </div> <!--//container-->
</section>
            
          
!
            
              @import "compass/css3";

@import "compass/reset";
@import "compass/css3";

$primary: #077ABC;
$red: #BC0731;
$green: #2ecc71;

*{
  @include box-sizing(border-box);
}
body{
	background-color: #fff;
   font-family: helvetica, arial, sans-serif;
}
a, input[type='checkbox']{
  display: inline-block;
  line-height: 2;
}
a{
  margin-right: 10px;
}
h1{
	font-family: helvetica;
  font-weight: 100;
  font-size: 24px;
  line-height: 3;
}

section{
  >div{
    text-align: center;
    padding: 4em 0;
  }
}

.btn{
  position: relative;
  cursor:pointer;
  display: inline-block;
  padding: 15px 30px;
  min-width: 300px;
  outline: none;
  background-color: $primary;
  border: 1px solid darken($primary, 6%);
  color: #fff;
  font-size: 18px;
	border-radius: 3px;
  overflow: hidden;
  @include transition(all .3s ease);
  &:hover{
    background-color: lighten($primary, 3%);
  }
  &:disabled{
    opacity: .5;
    cursor: auto;
    background-color: $primary;
  }
  &.error{
    background-color: $red;
    border: 1px solid darken($red, 6%);
  }
  &.success{
    background-color: $green;
    border: 1px solid darken($green, 6%);
  }
  .content, 
  .progress{
    position: relative;
  }
  
  .content{  
    z-index: 10;
    width: 100%;
    display: block;
    @include transition(all .4s ease);
    &:before{
      font-family: "FontAwesome";
      content: "\f00c saved";
      z-index:10;
      position: absolute;
      display: block;
      width: 100%;
     top: -39px;
    }
     &:after{
      content: "! Errors, please resolve";
      z-index:10;
      position: absolute;
      display: block;
      width: 100%;
     top: 39px;
    }
  }
  .progress{
    width: 100%;
    heiGht: 100%;
    position: absolute;
    background-color: red;
    left: 0;
    top: 0;
    z-index: 1;
    width: 0;
    background-color: lighten($primary, 10%);
  }
}
            
          
!
            
              $(function(){
  var button = $(".btn");
  button.on("click", function(){
    var $this = $(this);
    var progress = $this.find(".progress");
    var content = $this.find(".content")
    
		if( $("[type=checkbox]").is(':checked') ){
     console.log("error true")
      $this.addClass("error");
      content.animate({top : "-40px"}, 50);
      //content.text("Error, invalid file type");
    }else{
      content.text("Saving...");
      progress
    		.animate({width : "20%"})
    		.delay(100)
    		.animate({width : "60%"})
    		.delay(400)
    		.animate({width : "100%"}, 100, function(){
      		progress.fadeOut(function(){progress.css("width" , 0);
           content.animate({top : "40px"});
           $this.addClass("success");
           setTimeout(function(){
            content.text("Save & Apply");
            content.animate({top : "0px"});
             $this.removeClass("success");
            button.attr("disabled" , "disabled");
           }, 2000)                         
         })//callback
    	});   
    }//if
  });//button
  
  //RESET-------------------//
  $("a").on("click" , function(){
    button.removeAttr( "disabled" ).removeClass("success, error");
   $(".content").text("Save & Apply").animate({top : "0px"}, 50)
   $(".progress").css('display' , 'block');
   $("[type=checkbox]").attr('checked', false);
	return false;
  });
})//ready
            
          
!
999px
Loading ..................

Console