From 8c856602fc40e8a171c746efc657991ea34dc513 Mon Sep 17 00:00:00 2001 From: Stuart Knightley Date: Fri, 14 Jun 2013 13:19:14 -0700 Subject: [PATCH 1/3] Add consumed point picker --- trelloscrum.css | 4 ++-- trelloscrum.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/trelloscrum.css b/trelloscrum.css index 7f4d12f..3eec5b0 100644 --- a/trelloscrum.css +++ b/trelloscrum.css @@ -38,7 +38,7 @@ .picker { float: right; - padding-top: 5px; + line-height: 1.7em; } .points-done-icon{ @@ -65,6 +65,6 @@ display: none; } -.badge-points.consumed{ +.badge-points.consumed, .point-value.consumed{ opacity: 0.5; } diff --git a/trelloscrum.js b/trelloscrum.js index ae0eee8..ea02313 100644 --- a/trelloscrum.js +++ b/trelloscrum.js @@ -209,6 +209,20 @@ function showPointPicker() { // then click our button so it all gets saved away $(".card-detail-title .edit .js-save-edit").click(); + return false + })) + $picker.append('
'); + for (var i in _pointSeq) $picker.append($('').text(_pointSeq[i]).click(function(){ + var value = $(this).text(); + var $text = $('.card-detail-title .edit textarea'); + var text = $text.val(); + + // replace our new + $text[0].value=text.match(regC)?text.replace(regC, ' ['+value+']'): text + ' ['+value+']'; + + // then click our button so it all gets saved away + $(".card-detail-title .edit .js-save-edit").click(); + return false })) }; From a43718e26f4369ade902ef6f0a54c6bbcfd6bbbd Mon Sep 17 00:00:00 2001 From: Stuart Knightley Date: Fri, 14 Jun 2013 13:51:52 -0700 Subject: [PATCH 2/3] Refactor point pickers --- trelloscrum.js | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/trelloscrum.js b/trelloscrum.js index ea02313..f97f160 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,37 +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 $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; - - // then click our button so it all gets saved away - $(".card-detail-title .edit .js-save-edit").click(); - return false - })) + var $picker = $('
').appendTo('.card-detail-title .edit-controls'); + for (i in _pointSeq) $picker.append(createPointButton(_pointSeq[i], false)); $picker.append('
'); - for (var i in _pointSeq) $picker.append($('').text(_pointSeq[i]).click(function(){ - var value = $(this).text(); + for (i in _pointSeq) $picker.append(createPointButton(_pointSeq[i], true)); +} + +function createPointButton(points, isConsumed) { + var regex, value; + var klass = 'point-value'; + if (isConsumed) { + regex = regC; + klass += ' consumed'; + 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(regC)?text.replace(regC, ' ['+value+']'): text + ' ['+value+']'; + 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; From 4d41019d1bbc364f4a35c573fdea13dc7f9d41e5 Mon Sep 17 00:00:00 2001 From: Stuart Knightley Date: Fri, 14 Jun 2013 14:27:28 -0700 Subject: [PATCH 3/3] Add labels to pickers and improve styling --- trelloscrum.css | 8 ++++++-- trelloscrum.js | 14 +++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/trelloscrum.css b/trelloscrum.css index 3eec5b0..64faeec 100644 --- a/trelloscrum.css +++ b/trelloscrum.css @@ -38,7 +38,11 @@ .picker { float: right; - line-height: 1.7em; + padding-top: 5px; +} + +.consumed.picker { + padding-top: 0; } .points-done-icon{ @@ -65,6 +69,6 @@ display: none; } -.badge-points.consumed, .point-value.consumed{ +.badge-points.consumed, .consumed .point-value{ opacity: 0.5; } diff --git a/trelloscrum.js b/trelloscrum.js index f97f160..fed574e 100644 --- a/trelloscrum.js +++ b/trelloscrum.js @@ -201,25 +201,25 @@ function showPointPicker() { var i; if($(this).find('.picker').length) return; - var $picker = $('
').appendTo('.card-detail-title .edit-controls'); - for (i in _pointSeq) $picker.append(createPointButton(_pointSeq[i], false)); - $picker.append('
'); - for (i in _pointSeq) $picker.append(createPointButton(_pointSeq[i], true)); + 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; - var klass = 'point-value'; if (isConsumed) { regex = regC; - klass += ' consumed'; value = ' [' + points + ']'; } else { regex = reg; value = '(' + points + ') '; } - return $('').text(points).click(function(){ + return $('').text(points).click(function(){ var $text = $('.card-detail-title .edit textarea'); var text = $text.val();