Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                <html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<div class="fancy-list" width = 300>
  <div class="fancy-list-head">
    <h1>Callbacks</h1>
  </div>
  <ul id="callbacks" class="fancy-list-content-list" size = 5>
  </ul>
  <div class="fancy-list-footer">
    <input type="text" placeholder="Name" id="fancy-list-first-name">
    <input type="text" placeholder="Number" id="fancy-list-last-name">
    <button class="add">Add</button>
    <button class="remove">Remove</button>
  </div>
  <div class="break"></div>
</div>
</body>
</html>
              
            
!

CSS

              
                .fancy-list {
	border:1px solid #acacac;
	padding:0px;
	border-radius: 5px;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	box-shadow: 0px 0px 4px 2px rgba(172, 172, 172, 0.5);
	-moz-box-shadow: 0px 0px 4px 2px rgba(172, 172, 172, 0.5);
	-webkit-box-shadow: 0px 0px 4px 2px rgba(172, 172, 172, 0.5);
	background-color: #e8e8e8;
}
.fancy-list .fancy-list-head h1 {
	font-size: 16px;
	padding: 0px 0px 10px 20px;
	font-weight: bold;
}
.fancy-list p {
	font-size: 12px;
	padding: 10px 0px 10px 20px;
	margin-bottom: 0px;
}
.fancy-list .fancy-list-content-list {
	padding-left: 0px;
	background-color: #fff;
	height: 273px;
	overflow-y: scroll;
}
.fancy-list .fancy-list-content-list li {
	list-style-type: none;
	padding: 5px 20px 5px 20px;
	margin-left: 0px;
	border-bottom: 1px dashed #CCC;
	cursor: pointer;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}
.fancy-list-content-list li.selected {
	background: -moz-linear-gradient(top, #359cde, #015c98);
	background: -webkit-gradient(linear, left top, left bottom, from(#359cde), to(#015c98));
 filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#359cde', EndColorStr='#015c98');
	-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#359cde, endColorstr=#015c98)";
	color: #fff;
}
.fancy-list .fancy-list-footer {
	padding: 15px;
}
.fancy-list .fancy-list-footer input {
	width: 65px;
	height: 17px;
	margin-right: 5px;
}
.fancy-list .fancy-list-footer input#fancy-list-last-name {
	width: 100px;
}
.fancy-list .fancy-list-footer .btn {
	float: left;
	margin-left: 0px;
	padding: 2px 13px 3px 12px;
}
.fancy-list .person {
	color: #008de7;
	display: block;
	width: 100%;
	white-space: pre;           /* CSS 2.0 */
	white-space: pre-wrap;      /* CSS 2.1 */
	white-space: pre-line;      /* CSS 3.0 */
	white-space: -pre-wrap;     /* Opera 4-6 */
	white-space: -o-pre-wrap;   /* Opera 7 */
	white-space: -moz-pre-wrap; /* Mozilla */
	white-space: -hp-pre-wrap;  /* HP Printers */
	word-wrap: break-word;      /* IE 5+ */
}
.fancy-list .person .first {
	margin-right: 5px;
}
.fancy-list .selected .person {
	color: #fff;
}
              
            
!

JS

              
                $(document).ready( function()
{

	var _stack = [];
	function user( argument )
	{
		this.first_name = argument.first_name;
		this.last_name = argument.last_name;
	}
	
	$(".fancy-list").each( function()
	{
		_width = $(this).attr("width");
		if( _width != null )
			$(this).css("width", _width );
		_list = $(this).find(".fancy-list-content-list");
		_list_items =  _list.find("li").length;
		
		if( _list_items === 0 )
		{
			_list.html("<li style = 'display: none'><div class='person'>Person 1</div><div class='clear'></div></li>");
			list_item_height = _list.find("li").outerHeight();
			_list.html("");
		}
		else
			list_item_height = _list.find("li").outerHeight();
		
		
		list_size = _list.attr("size");
		
		_list.css("height", list_item_height * list_size);
		_list.find("li").click( function()
		{
			if( $(this).parent().hasClass("multi-select"))
			{
				if( $(this).hasClass("selected") )
					$(this).removeClass("selected");
				else
					$(this).addClass("selected");
			}
			else
			{		
				$(this).parent().find("li").removeClass("selected");
				$(this).addClass("selected");
			}
		});
	});

	function fancyList(elem) {
		
		var this_parent = elem.parents(".fancy-list");
		
		rel = this_parent.attr("rel");
                var regex = /(<([^>]+)>)/ig;
		
		first_name = this_parent.find(".fancy-list-footer input#fancy-list-first-name").val().replace(/[<\s]/g, "").replace(/[>\s]/g, "");
		last_name = this_parent.find(".fancy-list-footer input#fancy-list-last-name").val().replace(/[<\s]/g, "").replace(/[>\s]/g, "");
		if( (first_name !== "" || last_name !== "") && (first_name != "First" || last_name != "Last") )
		{
			if( first_name.toLowerCase() == "first" )
				name = last_name;
			else if( last_name.toLowerCase() == "last" )
				name = first_name;
			else
				name = first_name + " " + last_name;
						
			
			this_parent.find(".fancy-list-content-list:last").append("<li><div class='person'><span class = 'first'>" + first_name + "</span><span class = 'last'>" + last_name + "</span></div><div class='clear'></div></li>");
			
			var new_user = new user({"first_name": first_name, "last_name": last_name });
			_stack.push( new_user);
			
				
			this_parent.find(".fancy-list-footer input#fancy-list-first-name").val("").removeAttr('value');
			this_parent.find(".fancy-list-footer input#fancy-list-last-name").val("").removeAttr('value');

			this_parent.find(".fancy-list-content-list li:last").hide();
			this_parent.find(".fancy-list-content-list li:last").show(300);
			
            this_parent.find(".fancy-list-content-list li:last-child").dblclick( function() {
			console.log(first_name);
              
            if(confirm("Remove callback for: " + first_name + "?")) {
			  var cnt = document.getElementById("callbacks");	
              cnt.removeChild(this);
            }
            
					
			});
          
			//Attach click event to new item
			this_parent.find(".fancy-list-content-list li:last-child").click( function() {
				
				fancy_list = $(this).parents(".fancy-list");
				
				if( $(this).parent().hasClass("multi-select") )
				{
					if( $(this).hasClass("selected") )
						$(this).removeClass("selected"); 
					else
						$(this).addClass("selected");
				}
				else
				{
					$(".fancy-list-content-list li").removeClass("selected");
					$(this).addClass("selected");						
				}
					
			});
			/* End attach click to new item */
		}
		
	}
	
	$(".fancy-list-footer .add").click( function() {
		$('.tab-container .user-information .first-name:last').val('').removeClass('placeholder');
		$('.tab-container .user-information .last-name:last').val('').removeClass('placeholder');
		fancyList($(this));
	});
  $("fancy-list-footer .remove").click(function() {
 
  });
});
              
            
!
999px
Why did the programmer quit her job? She didn't get arrays.

Console