diff --git a/customize.dist/src/less2/include/tools.less b/customize.dist/src/less2/include/tools.less index 9fd2df5bc..b8c36cbcd 100644 --- a/customize.dist/src/less2/include/tools.less +++ b/customize.dist/src/less2/include/tools.less @@ -19,6 +19,7 @@ } .tools_unselectable () { + user-select: none; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; diff --git a/www/kanban/app-kanban.less b/www/kanban/app-kanban.less index db58861b6..f93d8ba4c 100644 --- a/www/kanban/app-kanban.less +++ b/www/kanban/app-kanban.less @@ -1,5 +1,6 @@ @import (once) "../../customize/src/less2/include/browser.less"; @import (once) "../../customize/src/less2/include/framework.less"; +@import (once) "../../customize/src/less2/include/tools.less"; .framework_main( @bg-color: @colortheme_kanban-bg, @warn-color: @colortheme_kanban-warn, @@ -13,13 +14,9 @@ min-height: auto; #cp-app-kanban-container { - display: inline-flex; + flex: 1; + display: flex; flex-flow: column; - height: 100%; - min-height: 100%; - width: 200%; - resize: horizontal; - overflow: hidden; } #cp-app-kanban-editor { flex: 1; @@ -28,6 +25,95 @@ height: 100%; overflow: hidden; } + #cp-app-kanban-content { + flex: 1; + overflow-y: auto; + display: flex; + flex-flow: column; + .kanban-container-outer { + flex: 1; + display: flex; + align-items: center; + .kanban-container { + flex: 1; + display: flex; + flex-wrap: wrap; + justify-content: space-evenly; + } + } + + .kanban-board { + header { + display: flex; + align-items: center; + .kanban-title-board { + flex: 1; + margin-right: 10px; + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + #kanban-edit { + color: black; + font-weight: bold; + } + } + } + } + + #kanban-edit { + width: 100%; + background: transparent; + border: 1px solid rgba(0,0,0,0.3); + } + + #kanban-addboard { + margin: 30px; + border: 1px solid; + width: 100px; + text-align: center; + background: @colortheme_kanban-bg; + font-weight: bold; + height: 100px; + align-self: flex-start; + font-size: 50px; + line-height: 100px; + cursor: pointer; + .tools_unselectable(); + } + + .kanban-removeboard { + float: right; + margin: 10px; + padding: 3px; + width: 30px; + text-align: center; + background: #eee; + font-weight: bold; + cursor: pointer; + .tools_unselectable(); + } + + .kanban-header-yellow { + background: #FC3; + } + + .kanban-header-orange { + background: #F91; + } + + .kanban-header-blue { + background: #0AC; + } + + .kanban-header-red { + background: #E43; + } + + .kanban-header-green { + background: #8C4; + } @media (max-width: @browser_media-medium-screen) { #cp-app-kanban-container { diff --git a/www/kanban/inner.js b/www/kanban/inner.js index 25634c0d4..d5fd57a66 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -21,7 +21,6 @@ define([ Modes, Messages) { - console.log(Messages); // Kanban code var initKanban = function (framework, boards) { @@ -64,6 +63,14 @@ define([ // Remove any existing elements $(".kanban-container-outer").remove(); + var getInput = function () { + return $('', { + 'type': 'text', + 'id': 'kanban-edit', + 'size': '30' + }); + }; + var kanban = new window.jKanban({ element: '#cp-app-kanban-content', gutter: '15px', @@ -80,30 +87,41 @@ define([ kanban.inEditMode = true; var name = $(el).text(); $(el).html(''); - $('') - .attr({ - 'type': 'text', - 'name': 'text', - 'id': 'kanban_edit', - 'size': '30', - 'value': name - }) - .appendTo(el); - $('#kanban_edit').focus(); - $('#kanban_edit').blur(function () { - var name = $('#kanban_edit').val(); + var $input = getInput().val(name).appendTo(el).focus(); + $input[0].select(); + var save = function () { + // Store the value + var name = $input.val(); + // Remove the input $(el).text(name); + // Save the value for the correct board var board = $(el.parentNode.parentNode).attr("data-id"); var pos = kanban.findElementPosition(el); - console.log(pos); - console.log(board); kanban.getBoardJSON(board).item[pos].title = name; kanban.onChange(); + // Unlock edit mode kanban.inEditMode = false; + }; + $input.blur(save); + $input.keydown(function (e) { + if (e.which === 13) { + e.preventDefault(); + e.stopPropagation(); + save(); + return; + } + if (e.which === 27) { + e.preventDefault(); + e.stopPropagation(); + $(el).text(name); + kanban.inEditMode = false; + return; + } }); }, - boardTitleClick: function (el) { + boardTitleClick: function (el, e) { + e.stopPropagation(); if (kanban.inEditMode) { console.log("An edit is already active"); return; @@ -111,25 +129,36 @@ define([ kanban.inEditMode = true; var name = $(el).text(); $(el).html(''); - $('') - .attr({ - 'type': 'text', - 'name': 'text', - 'id': 'kanban_edit', - 'size': '30', - 'value': name - }) - .appendTo(el); - $('#kanban_edit').focus(); - $('#kanban_edit').blur(function () { - var name = $('#kanban_edit').val(); + var $input = getInput().val(name).appendTo(el).focus(); + $input[0].select(); + var save = function () { + // Store the value + var name = $input.val(); + // Remove the input $(el).text(name); + // Save the value for the correct board var board = $(el.parentNode.parentNode).attr("data-id"); kanban.getBoardJSON(board).title = name; kanban.onChange(); + // Unlock edit mode kanban.inEditMode = false; + }; + $input.blur(save); + $input.keydown(function (e) { + if (e.which === 13) { + e.preventDefault(); + e.stopPropagation(); + save(); + return; + } + if (e.which === 27) { + e.preventDefault(); + e.stopPropagation(); + $(el).text(name); + kanban.inEditMode = false; + return; + } }); - }, colorClick: function (el) { console.log("in color click"); @@ -150,7 +179,7 @@ define([ kanban.onChange(); }, - removeClick: function (el, boardId) { + removeClick: function (el) { UI.confirm(Messages.kanban_deleteBoard, function (yes) { if (!yes) { return; } console.log("Delete board"); @@ -166,26 +195,41 @@ define([ kanban.onChange(); }); }, - buttonClick: function (el, boardId) { - console.log(el); - console.log(boardId); + buttonClick: function (el, boardId, e) { + e.stopPropagation(); + if (kanban.inEditMode) { + console.log("An edit is already active"); + return; + } + kanban.inEditMode = true; // create a form to enter element - var formItem = document.createElement('form'); - formItem.setAttribute("class", "itemform"); - formItem.innerHTML = '
'; - - kanban.addForm(boardId, formItem); - formItem.addEventListener("submit", function (e) { - e.preventDefault(); - var text = e.target[0].value; + var $item = $('