diff --git a/trelloscrum.css b/trelloscrum.css index 7f4d12f..64faeec 100644 --- a/trelloscrum.css +++ b/trelloscrum.css @@ -41,6 +41,10 @@ padding-top: 5px; } +.consumed.picker { + padding-top: 0; +} + .points-done-icon{ background-position: 0px 3px !important; background-repeat: no-repeat !important; @@ -65,6 +69,6 @@ display: none; } -.badge-points.consumed{ +.badge-points.consumed, .consumed .point-value{ opacity: 0.5; } diff --git a/trelloscrum.js b/trelloscrum.js index ae0eee8..fed574e 100644 --- a/trelloscrum.js +++ b/trelloscrum.js @@ -17,6 +17,8 @@ ** Samuel Gaus ** */ +/*global chrome */ +/*jshint browser: true, jquery:true */ //default story point picker sequence var _pointSeq = ['?', 0, .5, 1, 2, 3, 5, 8, 13, 21]; @@ -196,23 +198,44 @@ function ListCard(el, identifier){ //the story point picker function showPointPicker() { + var i; if($(this).find('.picker').length) return; - var $picker = $('
').appendTo('.card-detail-title .edit-controls'); - for (var i in _pointSeq) $picker.append($('').text(_pointSeq[i]).click(function(){ - var value = $(this).text(); + + var $controls = $('.card-detail-title .edit-controls'); + + var $estimated = $('
Estimated ').appendTo($controls); + for (i in _pointSeq) $estimated.append(createPointButton(_pointSeq[i], false)); + var $consumed = $('
Consumed ').appendTo($controls); + for (i in _pointSeq) $consumed.append(createPointButton(_pointSeq[i], true)); +} + +function createPointButton(points, isConsumed) { + var regex, value; + if (isConsumed) { + regex = regC; + value = ' [' + points + ']'; + } else { + regex = reg; + value = '(' + points + ') '; + } + + return $('').text(points).click(function(){ var $text = $('.card-detail-title .edit textarea'); var text = $text.val(); // replace our new - $text[0].value=text.match(reg)?text.replace(reg, '('+value+') '):'('+value+') ' + text; + if (text.match(regex)) { + $text[0].value = text.replace(regex, value); + } else { + $text[0].value = isConsumed ? text + value : value + text; + } // then click our button so it all gets saved away $(".card-detail-title .edit .js-save-edit").click(); - return false - })) -}; - + return false; + }); +} //for export var $excel_btn,$excel_dl;