<body>

    <div id="board" class="board">
    <div class="top-title">
        <h1>Kanbandilla</h1>
        <p>Organize your work like The Boss</p>
        <button class="create-column-btn">Add Column</button>
        <div class="create-input new-column-btn">
        	<span class="glyphicon glyphicon-ok new-column-ok"></span>
        	<input type="textbox" value="" id="inputNewColumn" class="input-add new-column-input" placeholder="Type column name + Enter">
        </div>
    </div>    
        <div class="column-container" id="column-container"></div>
    </div>

    
</div>

</body>
</html>
.create-column-btn, .new-column-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto; }

.column .glyphicon-ok, .new-column-ok {
  position: relative;
  float: right;
  background-color: #004966;
  font-size: 16px;
  color: #B9BFC2;
  cursor: pointer;
  transition: .2s;
  padding: 4px; }
  .column .glyphicon-ok:hover, .new-column-ok:hover {
    color: #fff; }

.column .input-add, .new-column-input {
  background-color: #004966;
  color: #B9BFC2;
  font-size: 12px;
  font-weight: thin;
  font-style: italic;
  float: right;
  width: 86.6%;
  border: 3px solid #004966;
  border-bottom: 1px solid #B9BFC2;
  margin-top: -3px;
  transition: .3s;
  outline: none; }
  .column .input-add:hover, .new-column-input:hover {
    color: #fff; }
  .column .input-add:focus, .new-column-input:focus {
    color: #fff; }
    .column .input-add:focus .glyphicon-ok, .new-column-input:focus .glyphicon-ok {
      color: #fff; }

.create-column-btn, .column-title {
  font-size: 25px;
  background-color: #004966;
  text-align: left;
  line-height: 45px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 20px; }

* {
  box-sizing: border-box; }

body {
  font-family: "Noto Sans", sans-serif;
  background-color: #8ED0EA; }

h1 {
  text-align: center;
  font-family: "Bungee", cursive;
  color: #004966; }

.board {
  position: relative; }
  .board p {
    font-family: "PT Mono", monospace;
    text-align: center;
    font-size: 15px;
    color: #004966; }

.column-container {
  width: calc(230px * 10); }

.column {
  position: relative;
  display: inline-block;
  width: 210px;
  color: #fff;
  transition: .3s;
  float: left;
  margin-top: 210px;
  padding-right: 10px; }
  .column:first-child {
    padding-left: 10px;
    width: 220px; }
  .column .glyphicon-remove {
    position: absolute;
    cursor: pointer;
    right: 0;
    color: #B9BFC2;
    font-size: 12px;
    padding-right: 13px;
    padding-top: 2px; }
    .column .glyphicon-remove:hover {
      color: #fff; }
  .column .input-add-div {
    height: 25px;
    width: 100%;
    margin-bottom: 5px;
    background-color: #004966; }

.create-column-btn {
  min-width: 210px;
  color: #fff;
  border: none;
  transition: .3s;
  outline: none;
  border-radius: 4px; }

.new-column-btn {
  position: relative;
  top: -4px;
  height: 29px;
  width: 210px;
  background-color: #004966;
  display: none;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px; }

.new-column-ok {
  border-bottom-right-radius: 4px;
  margin-top: 1px; }

.new-column-input {
  margin-top: 1px; }

.card {
  position: relative;
  background-color: #00A4E5;
  padding: 12px 12px 2px 12px;
  margin-bottom: 5px;
  transform: scale(1);
  box-shadow: 0 2px 2px #333;
  cursor: move; }
  .card p {
    color: #fff;
    font-size: 14px;
    font-family: "PT Mono", monospace;
    font-weight: 500; }
  .card:hover {
    box-shadow: 1px 3px 3px #444;
    transform: scale(1.01); }
  .card .glyphicon-remove {
    position: absolute;
    right: 0px;
    cursor: pointer;
    color: #006A94;
    padding: 2px;
    font-size: 12px; }
    .card .glyphicon-remove:hover {
      color: #fff; }

.column-title {
  margin: 0; }

.column-list {
  list-style-type: none;
  padding-left: 0;
  height: calc(100vh - 313px);
  overflow-x: hidden;
  overflow-y: auto; }

.card-placeholder {
  height: 60px;
  margin-top: 5px;
  background-color: #00A4E5;
  opacity: .3; }

.top-title {
  position: fixed;
  left: calc(50% - 142px); }

::-webkit-scrollbar {
  width: 6px;
  height: 10px; }

::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  -webkit-border-radius: 10px;
  border-radius: 10px; }

::-webkit-scrollbar-thumb {
  -webkit-border-radius: 10px;
  border-radius: 10px;
  background: rgba(0, 106, 148, 0.8);
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5); }

::-webkit-scrollbar-thumb:window-inactive {
  background: rgba(0, 106, 148, 0.4); }

.glyphicon-warning-sign {
  color: orange; }

.glyphicon-exclamation-sign {
  color: red; }



/*!
 * jquery-confirm v2.5.1 (https://craftpip.github.io/jquery-confirm/)
 * Author: boniface pereira
 * Website: www.craftpip.com
 * Contact: [email protected]
 *
 * Copyright 2013-2016 jquery-confirm
 * Licensed under MIT (https://github.com/craftpip/jquery-confirm/blob/master/LICENSE)
 */
@-webkit-keyframes jconfirm-rotate {
  from {
    -webkit-transform: rotate(0deg);
            transform: rotate(0deg);
  }
  to {
    -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
  }
}
@keyframes jconfirm-rotate {
  from {
    -webkit-transform: rotate(0deg);
            transform: rotate(0deg);
  }
  to {
    -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
  }
}
body.jconfirm-noscroll {
  overflow: hidden !important;
}
.jconfirm {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999999;
  font-family: inherit;
  overflow: hidden;
}
.jconfirm .jconfirm-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  -webkit-transition: all .4s;
          transition: all .4s;
}
.jconfirm .jconfirm-bg.seen {
  opacity: 1;
}
.jconfirm .jconfirm-scrollpane {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  -webkit-perspective: 500px;
          perspective: 500px;
  -webkit-perspective-origin: center;
          perspective-origin: center;
}
.jconfirm .jconfirm-box {
  background: white;
  border-radius: 4px;
  position: relative;
  outline: none;
  padding: 15px 15px 0;
}
.jconfirm .jconfirm-box div.closeIcon {
  height: 20px;
  width: 20px;
  position: absolute;
  top: 5px;
  right: 5px;
  cursor: pointer;
  opacity: .6;
  text-align: center;
  -webkit-transition: opacity 0.1s ease-in;
          transition: opacity 0.1s ease-in;
  display: none;
  font-size: 27px;
  line-height: 14px;
}
.jconfirm .jconfirm-box div.closeIcon .fa {
  font-size: 16px;
}
.jconfirm .jconfirm-box div.closeIcon .glyphicon {
  font-size: 16px;
}
.jconfirm .jconfirm-box div.closeIcon .zmdi {
  font-size: 16px;
}
.jconfirm .jconfirm-box div.closeIcon:hover {
  opacity: 1;
}
.jconfirm .jconfirm-box div.title-c {
  display: block;
  font-size: 22px;
  line-height: 20px;
}
.jconfirm .jconfirm-box div.title-c .icon-c {
  font-size: inherit;
  padding-bottom: 15px;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}
.jconfirm .jconfirm-box div.title-c .icon-c i {
  vertical-align: middle;
}
.jconfirm .jconfirm-box div.title-c .icon-c:empty {
  display: none;
}
.jconfirm .jconfirm-box div.title-c .title {
  font-size: inherit;
  font-family: inherit;
  display: inline-block;
  vertical-align: middle;
  padding-bottom: 15px;
}
.jconfirm .jconfirm-box div.title-c .title:empty {
  display: none;
}
.jconfirm .jconfirm-box div.content-pane {
  margin-bottom: 15px;
  height: auto;
  -webkit-transition: height 0.4s ease-in;
          transition: height 0.4s ease-in;
  display: inline-block;
  width: 100%;
  position: relative;
}
.jconfirm .jconfirm-box div.content-pane .content {
  position: absolute;
  top: 0;
  left: 0;
  -webkit-transition: all 0.2s ease-in;
          transition: all 0.2s ease-in;
  right: 0;
}
.jconfirm .jconfirm-box div.content-pane .content img {
  width: 100%;
  height: auto;
}
.jconfirm .jconfirm-box div.content-pane .content:empty {
  display: none;
}
.jconfirm .jconfirm-box div.content-pane .content:empty.loading {
  height: 40px;
  position: relative;
  opacity: 0.6;
  display: block;
}
.jconfirm .jconfirm-box div.content-pane .content:empty.loading:before {
  content: '';
  height: 20px;
  width: 20px;
  border: solid 2px transparent;
  position: absolute;
  left: 50%;
  margin-left: -10px;
  border-radius: 50%;
  -webkit-animation: jconfirm-rotate 1s infinite linear;
          animation: jconfirm-rotate 1s infinite linear;
  border-bottom-color: #aaa;
  top: 50%;
  margin-top: -10px;
}
.jconfirm .jconfirm-box div.content-pane .content:empty.loading:after {
  content: '';
  position: absolute;
  left: 50%;
  margin-left: -15px;
}
.jconfirm .jconfirm-box .buttons {
  padding-bottom: 15px;
}
.jconfirm .jconfirm-box .buttons button + button {
  margin-left: 5px;
}
.jconfirm .jquery-clear {
  clear: both;
}
.jconfirm.rtl {
  direction: rtl;
}
.jconfirm.rtl div.closeIcon {
  left: 12px;
  right: auto;
}
.jconfirm.jconfirm-white .jconfirm-bg {
  background-color: rgba(0, 0, 0, 0.2);
}
.jconfirm.jconfirm-white .jconfirm-box {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  border-radius: 5px;
}
.jconfirm.jconfirm-white .jconfirm-box .buttons {
  float: right;
}
.jconfirm.jconfirm-white .jconfirm-box .buttons button {
  border: none;
  background-image: none;
  text-transform: uppercase;
  font-size: 14px;
  font-weight: bold;
  text-shadow: none;
  -webkit-transition: background .1s;
          transition: background .1s;
  color: white;
}
.jconfirm.jconfirm-white .jconfirm-box .buttons button.btn-default {
  box-shadow: none;
  color: #333;
}
.jconfirm.jconfirm-white .jconfirm-box .buttons button.btn-default:hover {
  background: #ddd;
}
.jconfirm.jconfirm-black .jconfirm-bg {
  background-color: rgba(0, 0, 0, 0.5);
}
.jconfirm.jconfirm-black .jconfirm-box {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  background: #444;
  border-radius: 5px;
  color: white;
}
.jconfirm.jconfirm-black .jconfirm-box .buttons {
  float: right;
}
.jconfirm.jconfirm-black .jconfirm-box .buttons button {
  border: none;
  background-image: none;
  text-transform: uppercase;
  font-size: 14px;
  font-weight: bold;
  text-shadow: none;
  -webkit-transition: background .1s;
          transition: background .1s;
  color: white;
}
.jconfirm.jconfirm-black .jconfirm-box .buttons button.btn-default {
  box-shadow: none;
  color: #fff;
  background: none;
}
.jconfirm.jconfirm-black .jconfirm-box .buttons button.btn-default:hover {
  background: #666;
}
.jconfirm .jconfirm-box.hilight {
  -webkit-animation: hilight 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
          animation: hilight 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  -webkit-transform: translate3d(0, 0, 0);
          transform: translate3d(0, 0, 0);
}
@-webkit-keyframes hilight {
  10%,
  90% {
    -webkit-transform: translate3d(-2px, 0, 0);
            transform: translate3d(-2px, 0, 0);
  }
  20%,
  80% {
    -webkit-transform: translate3d(4px, 0, 0);
            transform: translate3d(4px, 0, 0);
  }
  30%,
  50%,
  70% {
    -webkit-transform: translate3d(-8px, 0, 0);
            transform: translate3d(-8px, 0, 0);
  }
  40%,
  60% {
    -webkit-transform: translate3d(8px, 0, 0);
            transform: translate3d(8px, 0, 0);
  }
}
@keyframes hilight {
  10%,
  90% {
    -webkit-transform: translate3d(-2px, 0, 0);
            transform: translate3d(-2px, 0, 0);
  }
  20%,
  80% {
    -webkit-transform: translate3d(4px, 0, 0);
            transform: translate3d(4px, 0, 0);
  }
  30%,
  50%,
  70% {
    -webkit-transform: translate3d(-8px, 0, 0);
            transform: translate3d(-8px, 0, 0);
  }
  40%,
  60% {
    -webkit-transform: translate3d(8px, 0, 0);
            transform: translate3d(8px, 0, 0);
  }
}
/*Transition rules*/
.jconfirm {
  -webkit-perspective: 400px;
          perspective: 400px;
}
.jconfirm .jconfirm-box {
  opacity: 1;
  -webkit-transition-property: -webkit-transform, opacity, box-shadow;
          transition-property: transform, opacity, box-shadow;
}
.jconfirm .jconfirm-box.anim-top,
.jconfirm .jconfirm-box.anim-left,
.jconfirm .jconfirm-box.anim-right,
.jconfirm .jconfirm-box.anim-bottom,
.jconfirm .jconfirm-box.anim-opacity,
.jconfirm .jconfirm-box.anim-zoom,
.jconfirm .jconfirm-box.anim-scale,
.jconfirm .jconfirm-box.anim-none,
.jconfirm .jconfirm-box.anim-rotate,
.jconfirm .jconfirm-box.anim-rotatex,
.jconfirm .jconfirm-box.anim-rotatey,
.jconfirm .jconfirm-box.anim-scaley,
.jconfirm .jconfirm-box.anim-scalex {
  opacity: 0;
}
.jconfirm .jconfirm-box.anim-rotate {
  -webkit-transform: rotate(90deg);
      -ms-transform: rotate(90deg);
          transform: rotate(90deg);
}
.jconfirm .jconfirm-box.anim-rotatex {
  -webkit-transform: rotateX(90deg);
          transform: rotateX(90deg);
  -webkit-transform-origin: center;
      -ms-transform-origin: center;
          transform-origin: center;
}
.jconfirm .jconfirm-box.anim-rotatexr {
  -webkit-transform: rotateX(-90deg);
          transform: rotateX(-90deg);
  -webkit-transform-origin: center;
      -ms-transform-origin: center;
          transform-origin: center;
}
.jconfirm .jconfirm-box.anim-rotatey {
  -webkit-transform: rotatey(90deg);
      -ms-transform: rotatey(90deg);
          transform: rotatey(90deg);
  -webkit-transform-origin: center;
      -ms-transform-origin: center;
          transform-origin: center;
}
.jconfirm .jconfirm-box.anim-rotateyr {
  -webkit-transform: rotatey(-90deg);
      -ms-transform: rotatey(-90deg);
          transform: rotatey(-90deg);
  -webkit-transform-origin: center;
      -ms-transform-origin: center;
          transform-origin: center;
}
.jconfirm .jconfirm-box.anim-scaley {
  -webkit-transform: scaley(1.5);
      -ms-transform: scaley(1.5);
          transform: scaley(1.5);
  -webkit-transform-origin: center;
      -ms-transform-origin: center;
          transform-origin: center;
}
.jconfirm .jconfirm-box.anim-scalex {
  -webkit-transform: scalex(1.5);
      -ms-transform: scalex(1.5);
          transform: scalex(1.5);
  -webkit-transform-origin: center;
      -ms-transform-origin: center;
          transform-origin: center;
}
.jconfirm .jconfirm-box.anim-top {
  -webkit-transform: translate(0px, -100px);
      -ms-transform: translate(0px, -100px);
          transform: translate(0px, -100px);
}
.jconfirm .jconfirm-box.anim-left {
  -webkit-transform: translate(-100px, 0px);
      -ms-transform: translate(-100px, 0px);
          transform: translate(-100px, 0px);
}
.jconfirm .jconfirm-box.anim-right {
  -webkit-transform: translate(100px, 0px);
      -ms-transform: translate(100px, 0px);
          transform: translate(100px, 0px);
}
.jconfirm .jconfirm-box.anim-bottom {
  -webkit-transform: translate(0px, 100px);
      -ms-transform: translate(0px, 100px);
          transform: translate(0px, 100px);
}
.jconfirm .jconfirm-box.anim-zoom {
  -webkit-transform: scale(1.2);
      -ms-transform: scale(1.2);
          transform: scale(1.2);
}
.jconfirm .jconfirm-box.anim-scale {
  -webkit-transform: scale(0.5);
      -ms-transform: scale(0.5);
          transform: scale(0.5);
}
.jconfirm .jconfirm-box.anim-none {
  display: none;
}
.jconfirm.jconfirm-supervan .jconfirm-bg {
  background-color: rgba(54, 70, 93, 0.95);
}
.jconfirm.jconfirm-supervan .jconfirm-box {
  background-color: transparent;
}
.jconfirm.jconfirm-supervan .jconfirm-box div.closeIcon {
  color: white;
}
.jconfirm.jconfirm-supervan .jconfirm-box div.title-c {
  text-align: center;
  color: white;
  font-size: 28px;
  font-weight: normal;
}
.jconfirm.jconfirm-supervan .jconfirm-box div.title-c > * {
  padding-bottom: 25px;
}
.jconfirm.jconfirm-supervan .jconfirm-box div.content-pane {
  margin-bottom: 25px;
}
.jconfirm.jconfirm-supervan .jconfirm-box div.content {
  text-align: center;
  color: white;
}
.jconfirm.jconfirm-supervan .jconfirm-box .buttons {
  text-align: center;
}
.jconfirm.jconfirm-supervan .jconfirm-box .buttons button {
  font-size: 16px;
  border-radius: 2px;
  background: #303f53;
  text-shadow: none;
  border: none;
  color: white;
  padding: 10px;
  min-width: 100px;
}
.jconfirm.jconfirm-material .jconfirm-bg {
  background-color: rgba(0, 0, 0, 0.67);
}
.jconfirm.jconfirm-material .jconfirm-box {
  background-color: white;
  box-shadow: 0 7px 8px -4px rgba(0, 0, 0, 0.2), 0 13px 19px 2px rgba(0, 0, 0, 0.14), 0 5px 24px 4px rgba(0, 0, 0, 0.12);
  padding: 30px 25px 10px 25px;
}
.jconfirm.jconfirm-material .jconfirm-box div.closeIcon {
  color: rgba(0, 0, 0, 0.87);
}
.jconfirm.jconfirm-material .jconfirm-box div.title-c {
  color: rgba(0, 0, 0, 0.87);
  font-size: 22px;
  font-weight: bold;
}
.jconfirm.jconfirm-material .jconfirm-box div.content {
  text-align: left;
  color: rgba(0, 0, 0, 0.87);
}
.jconfirm.jconfirm-material .jconfirm-box .buttons {
  text-align: right;
}
.jconfirm.jconfirm-material .jconfirm-box .buttons button {
  text-transform: uppercase;
  font-weight: 500;
}
.jconfirm.jconfirm-bootstrap .jconfirm-bg {
  background-color: rgba(0, 0, 0, 0.21);
}
.jconfirm.jconfirm-bootstrap .jconfirm-box {
  background-color: white;
  box-shadow: 0 3px 8px 0px rgba(0, 0, 0, 0.2);
  border: solid 1px rgba(0, 0, 0, 0.4);
  padding: 15px 0 0;
}
.jconfirm.jconfirm-bootstrap .jconfirm-box div.closeIcon {
  color: rgba(0, 0, 0, 0.87);
}
.jconfirm.jconfirm-bootstrap .jconfirm-box div.title-c {
  color: rgba(0, 0, 0, 0.87);
  font-size: 22px;
  font-weight: bold;
  padding-left: 15px;
  padding-right: 15px;
}
.jconfirm.jconfirm-bootstrap .jconfirm-box div.content {
  text-align: left;
  color: rgba(0, 0, 0, 0.87);
  padding: 0px 15px;
}
.jconfirm.jconfirm-bootstrap .jconfirm-box .buttons {
  text-align: right;
  padding: 0px 0 0px;
  margin: -5px 0 0px;
  border-top: solid 1px #ddd;
  overflow: hidden;
  border-radius: 0 0 4px 4px;
}
.jconfirm.jconfirm-bootstrap .jconfirm-box .buttons button {
  font-weight: 500;
  border-radius: 0px;
  margin: 0;
  border-left: solid 1px #ddd;
}
//AJAX Setup
var baseUrl = 'https://kodilla.com/pl/bootcamp-api';
var myHeaders = {
	'X-Client-Id': '16',
	'X-Auth-Token': '72c34b01532a9de1d8c49f69ac067d3f'
};

$.ajaxSetup({
	headers: myHeaders
});

$.ajax({
	url: baseUrl + '/board',
	method: 'GET',
	success: function(response) {
		setupColumns(response.columns);
	}
});

function setupColumns(columns) {
	columns.forEach(function (column) {
		var col = new Column(column.id, column.name);
		board.addColumn(col);
		setupCards(col, column.cards);
	});
}

function setupCards(col, cards) {
	cards.forEach(function (card) {
		var card = new Card(card.id, card.name, card.bootcamp_kanban_column_id);
		col.addCard(card);
	})
}

//Board
var board = {
	name: 'Tablica Kanban',
	addColumn: function(column) {
		this.$element.append(column.$element);
		initSortable();
	},
	$element: $('#board .column-container')
};

$('.create-column-btn').click(function() {
	$('.new-column-btn').slideToggle()
});

$('.new-column-ok').click(function() {
	var columnName = $('.new-column-input').val();

	if (!columnName) {
		$.confirm({
			icon: 'glyphicon glyphicon-warning-sign',
			title: "Type column name!",
			content: "Type column name or create default title",
			confirmButton: "Default",
			cancelButton: "Let me type",
			closeIcon: true,
    		closeIconClass: 'glyphicon glyphicon-remove',
		    confirm: function() {
				$.ajax({
					url: baseUrl + '/column',
					method: 'POST',
					data: {
						name: columnName
					},
					success: function(response) {
						var column = new Column(response.id, columnName);
						board.addColumn(column);
					}
				});
			}

		});
	} else {
		$.ajax({
			url: baseUrl + '/column',
			method: 'POST',
			data: {
				name: columnName
			},
			success: function(response) {
				var column = new Column(response.id, columnName);
				board.addColumn(column);
			}
		});
	}
	
	
	$('.new-column-btn').delay(500).slideToggle();
	$('.new-column-input').val('');

});

$('.new-column-input').on('keyup', function(e) {
    if (e.keyCode === 13) {
        $('.new-column-ok').click();
    }
});

function initSortable() {
	$('.column-list').sortable({
		connectWith: '.column-list',
		placeholder: 'card-placeholder',
	}).disableSelection();
}

//Column
function Column(id, name) {
	var self = this;

	this.id = id;
	this.name = name || '... Column ...';
	this.$element = createColumn();

	function createColumn() {
		var $row = $('<div>').addClass('row')
		var $column = $('<div>').addClass('column');
		var $columnTitle = $('<h2>').addClass('column-title').text(self.name);
		var $columnList = $('<ul>').addClass('column-list');
		var $icnRemove = $('<span>').addClass('glyphicon glyphicon-remove confirm'); // RoHell
		var $inputAddDiv = $('<div>').addClass('input-add-div'); //RoHell
		var $icnAdd = $('<span>').addClass('glyphicon glyphicon-ok add-card-ok'); // RoHell
  		var $inputAdd = $('<input>').attr({type: 'textbox', value: '', placeholder: 'Type card description + Enter'}).addClass('input-add input-card'); //RoHell

		var columnName = $('.new-column-input').val();
		var columnContainer = document.querySelector('.column-container');
		var columnsLength = columnContainer.querySelectorAll('.column').length;

		if ((columnsLength > 9) && (!columnName)) {
			$.alert({
				icon: 'glyphicon glyphicon-exclamation-sign',
				title: "Max column nr is 10!",
				content: "Please delete any column to create the new one.",				
    			confirmButton: 'OK',
    			closeIcon: true,
    			closeIconClass: 'glyphicon glyphicon-remove',
				confirm: function() {
					self.removeColumn();
				}
			});
		}

		$inputAdd.on('keyup', function(e) {
		    if (e.keyCode === 13) {
		        $icnAdd.click();
		    }
		});

		

	$icnRemove.click(function(event){
		console.log('event', event);
		var resulttt = event.currentTarget.parentNode.querySelector('.column-list');
		console.log('resulttt', resulttt);
		// resultttt jest naszym UL
		var listElementsPresent = resulttt.querySelector('li');
		if (!listElementsPresent) {
			console.log('uciekam z funkcji, nic nie robie');
			return self.removeColumn();
		}
		$.confirm({
			icon: 'glyphicon glyphicon-warning-sign',
			title: "Warning!",
			content: "This column contains Cards. Are you sure?",
			confirmButton: 'Yes, Remove It',
			cancelButton: 'No, Leave It!',
			closeIcon: true,
    		closeIconClass: 'glyphicon glyphicon-remove',
			confirm: function() {
				self.removeColumn();
			},
			cancel: function() {
			}
		});
	});

	$icnAdd.click(function() {

		var cardName = $inputAdd.val();		

		if (!cardName) {
			$.confirm({
				icon: 'glyphicon glyphicon-warning-sign',
				title: "Type card description!",
				content: "Type some description or leave it default",
			    confirmButton: "Default",
			    cancelButton: "Let me type",
			    closeIcon: true,
    			closeIconClass: 'glyphicon glyphicon-remove',
				confirm: function() {
					$.ajax({
						url: baseUrl + '/card',
						method: 'POST',
						data: {
							name: cardName,
							bootcamp_kanban_column_id: self.id
						},
						success: function(response) {
							var card = new Card(response.id, cardName);
							self.addCard(card);
						}
					});
				}
			});
		} else {
			$.ajax({
				url: baseUrl + '/card',
				method: 'POST',
				data: {
					name: cardName,
					bootcamp_kanban_column_id: self.id
				},
				success: function(response) {
					var card = new Card(response.id, cardName);
					self.addCard(card);
				}
			});
		}

		$('.input-card').val('');

	});

		$inputAddDiv.append($icnAdd)
              	.append($inputAdd);

		// $row.append($column);
		$column.append($columnTitle)
				.append($icnRemove)
      			.append($inputAddDiv)
				.append($columnList);
				
		return $column;
	}

}

Column.prototype.addCard = function(card) {
	this.$element.children('ul').append(card.$element);
};

Column.prototype.removeColumn = function() {
	var self = this;
	$.ajax({
		url: baseUrl + '/column/' + self.id,
		method: 'DELETE',
		success: function(response) {
			self.$element.remove();
		}
	});
};

//Card
function Card(id, name) {
	var self = this;

	this.id = id;
	this.name = name || '... Default card description...';
	this.$element = addCard();

	function addCard() {
		var $card = $('<li>').addClass('card');
		var $cardDescription = $('<p>').addClass('card-description').text(self.name);
		var $icnRemove = $('<span>').addClass('glyphicon glyphicon-remove');

		$icnRemove.click(function() {
			self.removeCard();
		});

		$card.append($icnRemove)
			.append($cardDescription);

		return $card;
	}
}


Card.prototype.removeCard = function() {
	var self = this;
	$.ajax({
		url: baseUrl + '/card/' + self.id,
		method: 'DELETE',
		success: function() {
			self.$element.remove();
		}
	});
};

//jQuery-confirm
/*!
 * jquery-confirm v2.5.1 (https://craftpip.github.io/jquery-confirm/)
 * Author: Boniface Pereira
 * Website: www.craftpip.com
 * Contact: [email protected]
 *
 * Copyright 2013-2015 jquery-confirm
 * Licensed under MIT (https://github.com/craftpip/jquery-confirm/blob/master/LICENSE)
 */

if (typeof jQuery === 'undefined') {
    throw new Error('jquery-confirm requires jQuery');
}

var jconfirm, Jconfirm;
(function ($) {
    "use strict";
        
    $.fn.confirm = function (options, option2) {        
        if (typeof options === 'undefined') options = {};
        if (typeof options === 'string')
            options = {
                content: options,
                title: (option2) ? option2 : false
                
            };
        /*
         *  Alias of $.confirm to emulate native confirm()
         */
        $(this).each(function () {
            var $this = $(this);
            $this.on('click', function (e) {
                e.preventDefault();
                var jcOption = $.extend({}, options);
                if ($this.attr('data-title'))
                    jcOption['title'] = $this.attr('data-title');
                if ($this.attr('data-content'))
                    jcOption['content'] = $this.attr('data-content');

                jcOption['$target'] = $this;
                if ($this.attr('href') && !options['confirm'])
                    jcOption['confirm'] = function () {
                        location.href = $this.attr('href');
                    };
                $.confirm(jcOption);
            });
        });
        return $(this);
    };
    $.confirm = function (options, option2) {
        if (typeof options === 'undefined') options = {};
        if (typeof options === 'string')
            options = {
                content: options,
                title: (option2) ? option2 : false
            };
        /*
         *  Alias of jconfirm
         */
        return jconfirm(options);
    };
    $.alert = function (options, option2) {
        if (typeof options === 'undefined') options = {};
        if (typeof options === 'string')
            options = {
                content: options,
                title: (option2) ? option2 : false
            };
        /*
         *  Alias of jconfirm
         */
        options.cancelButton = false;
        return jconfirm(options);
    };
    $.dialog = function (options, option2) {
        if (typeof options === 'undefined') options = {};
        if (typeof options === 'string')
            options = {
                content: options,
                title: (option2) ? option2 : false
            };
        /*
         *  Alias of jconfirm
         */
        options.cancelButton = false;
        options.confirmButton = false;
        options.confirmKeys = [13];
        return jconfirm(options);
    };
    jconfirm = function (options) {
        if (typeof options === 'undefined') options = {};
        /*
         * initial function for calling.
         */
        if (jconfirm.defaults) {
            /*
             * Merge global defaults with plugin defaults
             */
            $.extend(jconfirm.pluginDefaults, jconfirm.defaults);
        }
        /*
         * merge options with plugin defaults.
         */
        var options = $.extend({}, jconfirm.pluginDefaults, options);
        return new Jconfirm(options);
    };
    Jconfirm = function (options) {
        /*
         * constructor function Jconfirm,
         * options = user options.
         */
        $.extend(this, options);
        this._init();
    };
    Jconfirm.prototype = {
        _init: function () {
            var that = this;
            this._rand = Math.round(Math.random() * 99999);
            this._buildHTML();
            this._bindEvents();
            setTimeout(function () {
                that.open();
                that._watchContent();
            }, 0);
        },
        _buildHTML: function () {
            var that = this;
            /*
             * Prefixing animations.
             */
            this.animation = 'anim-' + this.animation.toLowerCase();
            this.closeAnimation = 'anim-' + this.closeAnimation.toLowerCase();
            this.theme = 'jconfirm-' + this.theme.toLowerCase();
            if (this.animation == 'anim-none')
                this.animationSpeed = 0;

            this._lastFocused = $('body').find(':focus');

            /*
             * Append html.
             */
            this.$el = $(this.template).appendTo(this.container).addClass(this.theme);
            this.$el.find('.jconfirm-box-container').addClass(this.columnClass);
            this.$el.find('.jconfirm-bg').css(this._getCSS(this.animationSpeed, 1));
            this.$el.find('.jconfirm-bg').css('opacity', this.opacity);
            this.$b = this.$el.find('.jconfirm-box').css(this._getCSS(this.animationSpeed, this.animationBounce)).addClass(this.animation);
            this.$body = this.$b; // alias

            /*
             * Add rtl class if rtl option has selected
             */
            if (this.rtl)
                this.$el.addClass("rtl");

            this._contentReady = $.Deferred();
            this._modalReady = $.Deferred();

            /*
             * Setup title contents
             */
            this.$title = this.$el.find('.title');
            this.contentDiv = this.$el.find('div.content');
            this.$content = this.contentDiv; // alias
            this.$contentPane = this.$el.find('.content-pane');
            this.$icon = this.$el.find('.icon-c');
            this.$closeIcon = this.$el.find('.closeIcon');
            this.$contentPane.css(this._getCSS(this.animationSpeed, 1));
            this.setTitle();
            this.setIcon();
            this._setButtons();

            if (this.closeIconClass)
                this.$closeIcon.html('<i class="' + this.closeIconClass + '"></i>');

            that._contentHash = this._hash(that.$content.html());
            $.when(this._contentReady, this._modalReady).then(function () {
                that.setContent();
                that.setTitle();
                that.setIcon();
            });

            this._getContent();
            this._imagesLoaded();

            if (this.autoClose)
                this._startCountDown();
        },
        _unwatchContent: function () {
            clearInterval(this._timer);
        },
        _hash: function () {
            return btoa((encodeURIComponent(this.$content.html())));
        },
        _watchContent: function () {
            var that = this;
            this._timer = setInterval(function () {
                var now = that._hash(that.$content.html());
                if (that._contentHash != now) {
                    that._contentHash = now;
                    that.setDialogCenter();
                    that._imagesLoaded();
                }
            }, this.watchInterval);
        },
        _bindEvents: function () {
            var that = this;
            var boxClicked = false;

            this.$el.find('.jconfirm-scrollpane').click(function (e) {
                // ignore propagated clicks
                if (!boxClicked) {
                    // background clicked
                    if (that.backgroundDismiss) {
                        that.cancel();
                        that.close();
                    } else {
                        that.$b.addClass('hilight');
                        setTimeout(function () {
                            that.$b.removeClass('hilight');
                        }, 800);
                    }
                }
                boxClicked = false;
            });

            this.$el.find('.jconfirm-box').click(function (e) {
                boxClicked = true;
            });

            if (this.$confirmButton) {
                this.$confirmButton.click(function (e) {
                    e.preventDefault();
                    var r = that.confirm(that.$b);
                    that._stopCountDown();
                    that.onAction('confirm');
                    if (typeof r === 'undefined' || r)
                        that.close();
                });
            }
            if (this.$cancelButton) {
                this.$cancelButton.click(function (e) {
                    e.preventDefault();
                    var r = that.cancel(that.$b);
                    that._stopCountDown();
                    that.onAction('cancel');

                    if (typeof r === 'undefined' || r)
                        that.close();
                });
            }
            if (this.$closeButton) {
                this.$closeButton.click(function (e) {
                    e.preventDefault();
                    that._stopCountDown();
                    that.cancel();
                    that.onAction('close');
                    that.close();
                });
            }
            if (this.keyboardEnabled) {
                setTimeout(function () {
                    $(window).on('keyup.' + this._rand, function (e) {
                        that.reactOnKey(e);
                    });
                }, 500);
            }

            $(window).on('resize.' + this._rand, function () {
                that.setDialogCenter(true);
            });
        },
        _getCSS: function (speed, bounce) {
            return {
                '-webkit-transition-duration': speed / 1000 + 's',
                'transition-duration': speed / 1000 + 's',
                '-webkit-transition-timing-function': 'cubic-bezier(.36,1.1,.2, ' + bounce + ')',
                'transition-timing-function': 'cubic-bezier(.36,1.1,.2, ' + bounce + ')'
            };
        },
        _imagesLoaded: function () {
            var that = this;
            $.each(this.$content.find('img:not(.loaded)'), function (i, a) {
                var interval = setInterval(function () {
                    var h = $(a).css('height');
                    if (h !== '0px') {
                        $(a).addClass('loaded');
                        that.setDialogCenter();
                        clearInterval(interval);
                    }
                }, 40);
            })
        },
        _setButtons: function () {
            /*
             * Settings up buttons
             */
            this.$btnc = this.$el.find('.buttons');
            if (this.confirmButton && $.trim(this.confirmButton) !== '') {
                this.$confirmButton = $('<button type="button" class="btn">' + this.confirmButton + '</button>').appendTo(this.$btnc).addClass(this.confirmButtonClass);
            }
            if (this.cancelButton && $.trim(this.cancelButton) !== '') {
                this.$cancelButton = $('<button type="button" class="btn">' + this.cancelButton + '</button>').appendTo(this.$btnc).addClass(this.cancelButtonClass);
            }
            if (!this.confirmButton && !this.cancelButton) {
                this.$btnc.hide();
            }
            if (!this.confirmButton && !this.cancelButton && this.closeIcon === null) {
                this.$closeButton = this.$b.find('.closeIcon').show();
            }
            if (this.closeIcon === true) {
                this.$closeButton = this.$b.find('.closeIcon').show();
            }
        },
        setTitle: function (string) {
            this.title = (typeof string !== 'undefined') ? string : this.title;
            this.$title.html(this.title || '');
        },
        setIcon: function (iconClass) {
            this.title = (typeof string !== 'undefined') ? iconClass : this.title;
            this.$icon.html(this.icon ? '<i class="' + this.icon + '"></i>' : '');
        },
        setContent: function (string) {
            // only set the content on the modal.
            var that = this;
            this.content = (typeof string == 'undefined') ? this.content : string;

            if (this.content == '') {
                this.$content.html(this.content);
                this.$contentPane.hide();
            } else {
                this.$content.html(this.content);
                this.$contentPane.show();
            }
            if (this.$content.hasClass('loading')) {
                this.$content.removeClass('loading');// it was loading via ajax.
                this.$btnc.find('button').prop('disabled', false);
            }
        },
        _getContent: function (string) {
            // get content from remote & stuff.
            var that = this;
            string = (string) ? string : this.content;
            this._isAjax = false;
            /*
             * Set content.
             */
            if (!this.content) { // if the content is falsy
                this.content = '';
                this.setContent(this.content);
                this._contentReady.reject();
            } else if (typeof this.content === 'string') {
                if (this.content.substr(0, 4).toLowerCase() === 'url:') {
                    this._isAjax = true;
                    this.$content.addClass('loading');
                    this.$btnc.find('button').prop('disabled', true);
                    var url = this.content.substring(4, this.content.length);
                    $.get(url).done(function (html) {
                        that.content = html;
                        that._contentReady.resolve();
                    }).always(function (data, status, xhr) {
                        if (typeof that.contentLoaded === 'function')
                            that.contentLoaded(data, status, xhr);
                    });
                } else {
                    this.setContent(this.content);
                    this._contentReady.reject();
                }
            } else if (typeof this.content === 'function') {
                this.$content.addClass('loading');
                this.$btnc.find('button').attr('disabled', 'disabled');
                var promise = this.content(this);
                if (typeof promise !== 'object') {
                    console.error('The content function must return jquery promise.');
                } else if (typeof promise.always !== 'function') {
                    console.error('The object returned is not a jquery promise.');
                } else {
                    this._isAjax = true;
                    promise.always(function (data, status) {
                        that._contentReady.resolve();
                    });
                }
            } else {
                console.error('Invalid option for property content, passed: ' + typeof this.content);
            }
            this.setDialogCenter();
        },
        _stopCountDown: function () {
            clearInterval(this.timerInterval);
            if (this.$cd)
                this.$cd.remove();
        },
        _startCountDown: function () {
            var opt = this.autoClose.split('|');
            if (/cancel/.test(opt[0]) && this.type === 'alert') {
                return false;
            } else if (/confirm|cancel/.test(opt[0])) {
                this.$cd = $('<span class="countdown">').appendTo(this['$' + opt[0] + 'Button']);
                var that = this;
                that.$cd.parent().click();
                var time = opt[1] / 1000;
                this.timerInterval = setInterval(function () {
                    that.$cd.html(' (' + (time -= 1) + ')');
                    if (time === 0) {
                        that.$cd.html('');
                        that.$cd.parent().trigger('click');
                        clearInterval(that.timerInterval);
                    }
                }, 1000);
            } else {
                console.error('Invalid option ' + opt[0] + ', must be confirm/cancel');
            }
        },
        reactOnKey: function key(e) {

            /*
             * prevent keyup event if the dialog is not last!
             */
            var a = $('.jconfirm');
            if (a.eq(a.length - 1)[0] !== this.$el[0])
                return false;

            var key = e.which;
            // Do not react if Enter/Space is pressed on input elements
            if (this.contentDiv.find(':input').is(':focus') && /13|32/.test(key))
                return false;

            if ($.inArray(key, this.cancelKeys) !== -1) {
                /*
                 * Cancel key pressed.
                 */
                if (this.$cancelButton) {
                    this.$cancelButton.click();
                } else {
                    this.close();
                }
            }
            if ($.inArray(key, this.confirmKeys) !== -1) {
                /*
                 * Confirm key pressed.
                 */
                if (this.$confirmButton) {
                    this.$confirmButton.click();
                }
            }
        },
        setDialogCenter: function () {
            if (this.$contentPane.css('display') == 'none') {
                var contentHeight = 0;
                var paneHeight = 0;
            } else {
                var contentHeight = this.$content.outerHeight();
                var paneHeight = this.$contentPane.height();
                if (paneHeight == 0)
                    paneHeight = contentHeight;
            }
            var off = 100;
            var w = this.$content.outerWidth();

            //var s = '-clip-path: inset(0px 0px '+contentHeight+'px 0px);' +
            //    'clip-path: inset(0px 0px '+contentHeight+'px 0px)';

            this.$content.css({
                'clip': 'rect(0px ' + (off + w) + 'px ' + contentHeight + 'px -' + off + 'px)'
            });

            this.$contentPane.css({
                'height': contentHeight
            });

            var windowHeight = $(window).height();
            var boxHeight = this.$b.outerHeight() - paneHeight + contentHeight;
            var topMargin = (windowHeight - boxHeight) / 2;
            var minMargin = 100;
            if (boxHeight > (windowHeight - minMargin)) {
                var style = {
                    'margin-top': minMargin / 2,
                    'margin-bottom': minMargin / 2
                }
                $('body').addClass('jconfirm-noscroll');
            } else {
                var style = {
                    'margin-top': topMargin
                }
                $('body').removeClass('jconfirm-noscroll');
            }
            this.$b.css(style);
        },
        close: function () {
            var that = this;

            if (this.isClosed())
                return false;

            if (typeof this.onClose === 'function')
                this.onClose();

            this._unwatchContent();
            that._lastFocused.focus();

            //this.observer.disconnect();
            /*
             unbind the window resize & keyup event.
             */
            $(window).unbind('resize.' + this._rand);
            if (this.keyboardEnabled)
                $(window).unbind('keyup.' + this._rand);

            that.$el.find('.jconfirm-bg').removeClass('seen');
            $('body').removeClass('jconfirm-noscroll');

            this.$b.addClass(this.closeAnimation);
            var closeTimer = (this.closeAnimation == 'anim-none') ? 0 : this.animationSpeed;
            setTimeout(function () {
                that.$el.remove();
            }, closeTimer * 25 / 100);

            jconfirm.record.closed += 1;
            jconfirm.record.currentlyOpen -= 1;

            return true;
        },
        open: function () {
            var that = this;
            if (this.isClosed())
                return false;

            that.$el.find('.jconfirm-bg').addClass('seen');           
            this.$b.removeClass(this.animation);
            this.$b.find('input[autofocus]:visible:first').focus();
            jconfirm.record.opened += 1;
            jconfirm.record.currentlyOpen += 1;
            if (typeof this.onOpen === 'function')
                this.onOpen();

            var jcr = 'jconfirm-box' + this._rand;
            this.$b.attr('aria-labelledby', jcr).attr('tabindex', -1).focus();
            if (this.$title)
                this.$title.attr('id', jcr); else if (this.$content)
                this.$content.attr('id', jcr);

            setTimeout(function () {
                that.$b.css({
                    'transition-property': that.$b.css('transition-property') + ', margin'
                });
                that._modalReady.resolve();
            }, this.animationSpeed);

            return true;
        },
        isClosed: function () {
            return this.$el.css('display') === '';
        }
    };

    jconfirm.pluginDefaults = {
        template: '<div class="jconfirm"><div class="jconfirm-bg"></div><div class="jconfirm-scrollpane"><div class="container"><div class="row"><div class="jconfirm-box-container"><div class="jconfirm-box" role="dialog" aria-labelledby="labelled" tabindex="-1"><div class="closeIcon">&times;</div><div class="title-c"><span class="icon-c"></span><span class="title"></span></div><div class="content-pane"><div class="content"></div></div><div class="buttons"></div><div class="jquery-clear"></div></div></div></div></div></div></div>',
        title: 'Hello',
        content: 'Are you sure to continue?',
        contentLoaded: function () {
        },
        icon: '',    
        opacity: 0.2,
        confirmButton: 'Okay',
        cancelButton: 'Close',
        confirmButtonClass: 'btn-default',
        cancelButtonClass: 'btn-default',
        theme: 'white',
        animation: 'zoom',
        closeAnimation: 'scale',
        animationSpeed: 500,
        animationBounce: 1.2,
        keyboardEnabled: false,
        rtl: false,
        confirmKeys: [13], // ENTER key
        cancelKeys: [27], // ESC key
        container: 'body',
        confirm: function () {
        },
        cancel: function () {
        },
        backgroundDismiss: false,
        autoClose: false,
        closeIcon: null,
        closeIconClass: false,
        watchInterval: 100,
        columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1',
        onOpen: function () {
        },
        onClose: function () {
        },
        onAction: function () {
        }
    };

    jconfirm.record = {
        opened: 0,
        closed: 0,
        currentlyOpen: 0
    };
})(jQuery);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.