cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <html>

<head>

  <meta charset="UTF-8">

  <title>Custom Events Support - Thanks to Tushar Sonawane </title>

    <!-- 2- Incluir AniCollection.css library -->
    <link rel="stylesheet" href="http://anijs.github.io/lib/anicollection/anicollection.css">
    
</head>

<body>

  <body>
	<div class="question">
		<div class="question-screen" data-anijs="if: answerSuccess, on: $Security, do: rubberBand animated, after: removeAnim">
			<div class="app-title">
				<h2 id="loadajax">Answer Please :)</h2>
			</div>

			<div class="question-form">
				<div class="control-group">
				<input type="text" class="question-field" id="questionfield" value="8 + 6 * 3 ?" placeholder="How much is 8 + 6 * 3 ?" id="question-name">
				<label class="question-field-icon fui-user" for="question-name"></label>
				</div>

				<div class="control-group">
				<input data-anijs="if: answerError, on: $Security, do: bad, after: removeAnim" id="answerfield" class="question-field" value="" placeholder="Answer here" id="question-pass">
				<label class="question-field-icon fui-lock" for="question-pass"></label>
				</div>

				<a id="questionButton" data-anijs="if: animationend, on: input, do: rollOut animated, to: div.question-screen, after: removeAnim; if: click, do: pulse animated, to: .question-screen, after: removeAnim" class="btn btn-primary btn-large btn-block" href="#">Answer me!</a>
				<a class="question-link" href="http://anijs.github.io/">Discover AniJS</a>
			</div>
		</div>
	</div>
</body>
</html>
            
          
!
            
              /* Note: Prefixes omitted, see below */
.bad {
	-webkit-animation-name: color_change;
	animation-name: color_change;
	-webkit-animation-duration: 1s;
	animation-duration: 1s;
	-webkit-animation-iteration-count: 1;
	animation-iteration-count: 1;
}

@-webkit-keyframes color_change {
	from { border-color: white; color: #FF6530;}
	to { border-color: #FF6530; color: #FF6530;}
}

@-moz-keyframes color_change {
	from { border-color: white; color: #FF6530;}
	to { border-color: #FF6530; color: #FF6530;}
}
@-o-keyframes color_change {
	from { border-color: white; color: #FF6530;}
	to { border-color: #FF6530; color: #FF6530;}
}
@keyframes color_change {
	from { border-color: white; color: #FF6530;}
	to { border-color: #FF6530; color: #FF6530;}
}


* {
-moz-box-sizing: border-box;
box-sizing: border-box;
}

*:focus {
	outline: none;
}
body {
	font-family: Arial;
	background-color: #3498DB;
	padding: 50px;
}
.question {
	margin: 20px auto;
	width: 300px;
}
.question-screen {
	background-color: #FFF;
	padding: 20px;
	border-radius: 5px
}

.app-title {
	text-align: center;
	color: #777;
}

.question-form {
	text-align: center;
}
.control-group {
	margin-bottom: 10px;
}

input {
	text-align: center;
	background-color: #ECF0F1;
	border: 2px solid transparent;
	border-radius: 3px;
	font-size: 16px;
	font-weight: 200;
	padding: 10px 0;
	width: 250px;
	-webkit-transition: border .5s;
	transition: border .5s;
}

input:focus {
	border: 2px solid #3498DB;
	box-shadow: none;
}

.btn {
	border: 2px solid transparent;
	background: #3498DB;
	color: #ffffff;
	font-size: 16px;
	line-height: 25px;
	padding: 10px 0;
	text-decoration: none;
	text-shadow: none;
	border-radius: 3px;
	box-shadow: none;
	-webkit-transition: 0.25s;
	transition: 0.25s;
	display: block;
	width: 250px;
	margin: 0 auto;
}

.btn:hover {
	background-color: #2980B9;
}

.question-link {
	font-size: 12px;
	color: #444;
	display: block;
	margin-top: 12px;
}
            
          
!
            
              		AniJS.run();
		var MyApp = {};

		//Obtaining the Notifier
		MyApp.SecurityNotifier = AniJS.getNotifier('Security');

		MyApp.processError = function(message){

			//Right now the events triggered by SecurityNotifier can be listened by AniJS
			$(MyApp.SecurityNotifier).trigger('answerError');
			document.getElementById('loadajax').innerHTML = message;
		}

		MyApp.processSuccess = function(message){

			//Right now the events triggered by SecurityNotifier can be listened by AniJS
			$(MyApp.Notifier).trigger('answerSuccess');
			document.getElementById('loadajax').innerHTML = message;
		}


		//Using native API to listen for the user click
		//https://developer.mozilla.org/en-US/docs/Web/API/Event
		formButton = document.getElementById("questionButton");
		questionButton.addEventListener('click', function(e){

			var request = document.getElementById('answerfield').value;

			document.getElementById('loadajax').innerHTML = 'Processing...';
	

			//Now you can wait for an Ajax Response
			MyApp.someAjaxModule.getResponse(request, function(response){

				if(response.error){
					MyApp.processError(response.error);
				} else{
					MyApp.processSuccess(response.success);
				}
				
			})
		

		}, false);

		//It's just a simulation
		MyApp.someAjaxModule = {
			getResponse: function(data, callback){
				var response = {};
				if( data === '26'){
					response.success = 'Cool :)';
				} else {
					response.error = 'Bad :(';
				}
				setTimeout(function(){
					callback(response);
				}, 1300)
			}
		}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console