Skip to content

Commit

Permalink
Merge pull request #104 from fotrino/master
Browse files Browse the repository at this point in the history
addItem Options
riktar authored Dec 1, 2020
2 parents 5617498 + dabb2fd commit 0443b52
Showing 7 changed files with 128 additions and 50 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -38,8 +38,12 @@ var kanban = new jKanban({
dragItems : true, // if false, all items are not draggable
boards : [], // json of boards
dragBoards : true, // the boards are draggable, if false only item can be dragged
addItemButton : false, // add a button to board for easy item creation
buttonContent : '+', // text or html content of the board button
itemAddOptions: {
enabled: false, // add a button to board for easy item creation
content: '+', // text or html content of the board button
class: 'kanban-title-button btn btn-default btn-xs', // default class of the button
footer: false // position the button on footer
},
itemHandleOptions: {
enabled : false, // if board item handle is enabled or not
handleClass : "item_handle", // css class for your custom item handle
74 changes: 53 additions & 21 deletions dist/jkanban.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jkanban.min.js

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
@@ -38,6 +38,18 @@
.error {
background: #fb7d44;
}

.custom-button {
background-color: #4CAF50;
border: none;
color: white;
padding: 7px 15px;
margin: 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
</style>
</head>
<body>
@@ -88,7 +100,12 @@
formItem.parentNode.removeChild(formItem);
};
},
addItemButton: true,
itemAddOptions: {
enabled: true,
content: '+ Add New Card',
class: 'custom-button',
footer: true
},
boards: [
{
id: "_todo",
45 changes: 26 additions & 19 deletions jkanban.js
Original file line number Diff line number Diff line change
@@ -15,6 +15,9 @@ var dragula = require("dragula");
var __DEFAULT_ITEM_HANDLE_OPTIONS = {
enabled: false
}
var __DEFAULT_ITEM_ADD_OPTIONS = {
enabled: false
}
this._disallowedItemProperties = [
"id",
"title",
@@ -31,8 +34,7 @@ var dragula = require("dragula");
this.dragula = dragula;
this.drake = "";
this.drakeBoard = "";
this.addItemButton = false;
this.buttonContent = "+";
this.itemAddOptions = __DEFAULT_ITEM_ADD_OPTIONS;
this.itemHandleOptions = __DEFAULT_ITEM_HANDLE_OPTIONS;
var defaults = {
element: "",
@@ -43,8 +45,7 @@ var dragula = require("dragula");
boards: [],
dragBoards: true,
dragItems: true, //whether can drag cards or not, useful when set permissions on it.
addItemButton: false,
buttonContent: "+",
itemAddOptions: __DEFAULT_ITEM_ADD_OPTIONS,
itemHandleOptions: __DEFAULT_ITEM_HANDLE_OPTIONS,
dragEl: function(el, source) {},
dragendEl: function(el) {},
@@ -236,8 +237,10 @@ var dragula = require("dragula");
} else {
var boardWidth = self.options.widthBoard;
}
var addButton = self.options.addItemButton;
var buttonContent = self.options.buttonContent;
var addButton = self.options.itemAddOptions.enabled;
var buttonContent = self.options.itemAddOptions.content;
var buttonClass = self.options.itemAddOptions.class;
var buttonFooter = self.options.itemAddOptions.footer;

//for on all the boards
for (var boardkey in boards) {
@@ -286,19 +289,6 @@ var dragula = require("dragula");
});
headerBoard.innerHTML =
'<div class="kanban-title-board">' + board.title + "</div>";
// if add button is true, add button to the board
if (addButton) {
var btn = document.createElement("BUTTON");
var t = document.createTextNode(buttonContent);
btn.setAttribute(
"class",
"kanban-title-button btn btn-default btn-xs"
);
btn.appendChild(t);
//var buttonHtml = '<button class="kanban-title-button btn btn-default btn-xs">'+buttonContent+'</button>'
headerBoard.appendChild(btn);
__onButtonClickHandler(btn, board.id);
}
//content board
var contentBoard = document.createElement("main");
contentBoard.classList.add("kanban-drag");
@@ -339,6 +329,23 @@ var dragula = require("dragula");
}
//footer board
var footerBoard = document.createElement("footer");
// if add button is true, add button to the board
if (addButton) {
var btn = document.createElement("BUTTON");
var t = document.createTextNode(buttonContent ? buttonContent : "+");
btn.setAttribute(
"class",
buttonClass ? buttonClass : 'kanban-title-button btn btn-default btn-xs'
);
btn.appendChild(t);
//var buttonHtml = '<button class="kanban-title-button btn btn-default btn-xs">'+buttonContent+'</button>'
if (buttonFooter) {
footerBoard.appendChild(btn);
} else {
headerBoard.appendChild(btn);
}
__onButtonClickHandler(btn, board.id);
}
//board assembly
boardNode.appendChild(headerBoard);
boardNode.appendChild(contentBoard);
28 changes: 23 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -39,6 +39,6 @@
"browserify": "^16.5.2",
"clean-css-cli": "^4.3.0",
"npm-css": "0.2.3",
"uglify-js": "^3.10.1"
"uglify-es": "^3.3.9"
}
}

0 comments on commit 0443b52

Please sign in to comment.